Willkommen bei WordPress. Dies ist dein erster Beitrag. Bearbeite oder lösche ihn und beginne mit dem Schreiben!
Blog
-
Nohup Without Nohup.out
his is a common question: how can I run
nohupwithout creating the annoyingnohup.out? And the common answer is: you can’t. But this is not exactly true.Some people have a dreadful habit of starting their applications using
nohupwith debug sent tostdout. Thenohup.outwill never be “rotated”, unlike a log file. It will keep growing until it consumes all available space. Even if you delete it or empty it out, the filesystem space will not be released, until the process wring to the file is terminated.And so without further ado, lo and behold: running
nohupwithout creatingnohup.out:nohup your_command </dev/null >/dev/null 2>&1 &
And here’s a little example. First, I
rsync/etc to /etc_mirror usingnohupto keep it running in the background:[root@ncc1701 tmp]# mkdir /etc_mirror
[root@ncc1701 tmp]# nohup rsync -av /etc/ /etc_mirror/ &
[2] 56919
[root@ncc1701 tmp]# nohup: ignoring input and appending output to `nohup.out‘
[root@ncc1701 tmp]#

[root@ncc1701 tmp]#
[2]- Done nohup rsync -av /etc/ /etc_mirror/
[root@ncc1701 tmp]# du -sh /etc /etc_mirror
118M /etc
118M /etc_mirror
[root@ncc1701 tmp]# wc -l nohup.out
3565 nohup.out
[root@ncc1701 tmp]# rm nohup.out
[root@ncc1701 tmp]# rm -r /etc_mirror
Here I repeat the same process with the
</dev/nulladdition:[root@ncc1701 tmp]# mkdir /etc_mirror
[root@ncc1701 tmp]# nohup rsync -av /etc/ /etc_mirror/ </dev/null >/dev/null 2>&1 &
[2] 61837
[root@ncc1701 tmp]#
[root@ncc1701 tmp]#
[2]- Done nohup rsync -av /etc/ /etc_mirror/ < /dev/null > /dev/null 2>&1
[root@ncc1701 tmp]# du -sh /etc /etc_mirror
118M /etc
118M /etc_mirror
[root@ncc1701 tmp]# wc -l nohup.out
wc: nohup.out: No such file or directory
[root@ncc1701 tmp]# rm -r /etc_mirror
Hooray.
