0

I am on Ubuntu 14.04 (using Digital Ocean) trying run a script as root. It's a script to check if a server is running and restart if it has crashed.

The issue isn't the script, but crontab won't run the script.

sudo crontab -e

#!/bin/bash
SHELL=/bin/bash
* * * * * /bin/bash /root/launch.sh
#newline

-rwxr-xr-x 1 root root 845 Nov 23 06:21 launch.sh

Not sure what I'm doing incorrectly, other posts about crontabs have shown similar answers to this one.

migrated from stackoverflow.com Nov 23 '14 at 15:14

This question came from our site for professional and enthusiast programmers.

  • The syntax for root's crontab is different. – tripleee Nov 23 '14 at 13:36
0

I found an answer to my problem.

I added my bash commands to /etc/crontab and added the root field instead of using sudo crontab -e

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*  *    * * *   root    bash /root/launch.sh

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.