LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Blogs > Skaperen
User Name
Password

Notices

Rate this Entry

Run cron jobs using screen

Posted 09-28-2012 at 12:02 AM by Skaperen
Updated 11-12-2012 at 06:40 PM by Skaperen

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.
Posted in Uncategorized
Views 1020 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration