Reputation: 10689
I'm really stuck. I've used cron on many machines, but I simply can not get it to work on an Ubuntu server. I've tried everything I can think over the weekend and I'm baffled. I'm hoping someone can help me out.
I can verify that cron is running via pgrep cron
. However, pgrep crond
returns nothing. I am trying to run a simple shell script (test.sh) with cron:
#!/bin/sh
/usr/bin/touch /home/jarvis/test.txt
I have run chmod +x
on the shell script and my crontab looks like this:
01 * * * * /home/jarvis/test.sh
I also have a new line ending after the line.
Upvotes: 1
Views: 926
Reputation: 1173
I think it is related to the user permissions. Try putting in default crontab hourly,weekly files, if it works there then your cron is good. Also, check /var/log/messages for any cron entry. View /etc/crontab for detailed configuration.
Upvotes: 0
Reputation: 37268
Try redirecting all output to a file and see if there are any error messages that can help you diagnose the problme, i.e.
01 * * * * /home/jarvis/test.sh > /tmp/jarvis_test.log 2>&1
Also, if you created any of those files from a windows environment, don't forget dos2unix filename
edit
My point is that you won't know for what your script is doing in the crontab environment unless you see if it is outputing an error message. Error messages also go to local crontab user's email, so try mail
(as the same user) and see if you have a bunch of messages from your crontab.
pgrep crond
returning nothing sounds like the problem, but I'm not a sysadmin. Maybe you want to flag this and ask for moderator to move to https://serverfault.com/
I hope this helps.
Upvotes: 1