Linux – Restart crontab @reboot rule without actual reboot

cronlinux

I'm using crontab with a @reboot entry which starts a script containing a endless while-loop that is processing the output of a tail -F command. Is there any way to stop the currently running script and restart the @reboot rule without a actual reboot? I'm running Debian 6.

Best Answer

I'm assuming you know the name of the script (use pkill), or can find out its processid (ps aux, then kill -9). Then start it again using the same command as in crontab. If you want to detach the process from the session, you can use nhup, or dtach or something similar.

Its pretty trivial. A better way to do this would be to write a init (or upstart or systemd) script, so you can just stop and start the service from there. This will depend on your distro, however.