Friday, June 6, 2014

OSX cronjob with GNU screen fails to run reporting "Must be connected to a terminal."


OSX crontab (cronjob) with GNU "screen" fails to run reporting "Must be connected to a terminal."


I had set a cronjob to run using the "screen" command,

0 * * * * /path/to/script.sh


where my script is:

#!/bin/bash
/usr/bin/screen -S taskname /usr/bin/nice mycommand


but it failed to run.  To figure out the problem, i redirected output to a log.

0 * * * * /path/to/script.sh > ~/mylog.log


The log reported "Must be connected to a terminal."

The solution is to add the -d -m options to screen:

#!/bin/bash
/usr/bin/screen -d -m -S taskname /usr/bin/nice mycommand


w00t!

-------

No comments:

Post a Comment

Comments, Suggestions or "Thank you's" Invited!