Run cron jobs using screen
I now run many (and soon to be most) of my cron jobs under the screen program. This is easily done by using the screen options "-dmS" followed by the screen session name to use, followed by the command to be run. This will quickly exit, leaving the command running in the disconnected screen session. This seems to work just fine through cron.
You can do this one of two different ways. The simple way is to specify the screen command in the crontab job file directly. Another way for more complicated jobs is to have a cron job script which does the screen command, and cron runs this script.
One advantage of this, especially if you use a session naming standard, such as prefixing all session names for cron jobs with "cron-" or such, is that you can do the "screen -ls" command to see what's currently running. Or you can do a screen attach to actually see the current output state of that cron job.
For other cases where you might want to run commands manually, the "screen -dmS sessionname command" approach is a less messy way to put things in the background.
You can do this one of two different ways. The simple way is to specify the screen command in the crontab job file directly. Another way for more complicated jobs is to have a cron job script which does the screen command, and cron runs this script.
One advantage of this, especially if you use a session naming standard, such as prefixing all session names for cron jobs with "cron-" or such, is that you can do the "screen -ls" command to see what's currently running. Or you can do a screen attach to actually see the current output state of that cron job.
For other cases where you might want to run commands manually, the "screen -dmS sessionname command" approach is a less messy way to put things in the background.
Total Comments 0