Cron won't run my root script

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.

1

1 Answer

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like