I want to run a Perl script with some while(1) loop in the background on a unix machine until I kill it.
This is a remote computer to which I don't have administrative permissions (so for some reason, I can't use Daemon::Generic::While1), I log to it through SSH, and I want it to continue to run after I log out.
One way I found out is write something like this to bash:
nohup ./my_script.pl &
Is there some other, more preferable way to do it?
Editing the crontab is forbidden on that computer (while running background and long-lasting processes isn't).
My preferred method, and arguably the easiest, is using screen
:
screen -d -m ./myProcess
You need to close stdout, stderr, stdin, otherwise you are still bound to that specific TTY
./my_script.pl >/dev/null 2>&1 </dev/null &
This should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With