Your $PATH
is fine; leave it alone. On Ubuntu, all the commands you're invoking (touch
, chmod
, curl
) are in /bin
and/or /usr/bin
.
How did you set up the cron job? Did you run crontab some-file
as root?
It seems that /etc/crontab
is the usual mechanism for running cron commands as root. On my Ubuntu system, sudo crontab -l
says no crontab for root
. Running crontab
as root, as you would for any non-root account, should be ok, but you might consider using /etc/crontab
instead. Note that it uses a different syntax than an ordinary crontab, as explained in the comments at the top of /etc/crontab
:
$ head -5 /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
Run sudo crontab -l
. Does it show your command?
Temporarily modify your script so it always produces some visible output. For example, add the following right after the #!/bin/sh
:
echo "Running scheduleSpider.sh at \`date\`" >> /tmp/scheduleSpider.sh.log
and see what's in /tmp/scheduleSpider.sh.log
after a few minutes. (You can set the command to run every minute so you don't have to wait as long for results.) If that works (it should), you can add more echo
commands to your script to see in detail what it's doing.
It looks like your script is designed to run only once; it creates the sync.txt
file to prevent it from running again. That could be the root (ahem) of your problem. What that your intent? Did you mean to delete sync.txt
after running the command, and just forgot to do it?
root
's home directory on Ubuntu is /root
. The first time your script runs, it should create /root/sync.txt
. Does that file exist? If so, how old is it?
Note that curl someLink
(assuming someLink
is a valid URL) will just dump the content from the specified link to standard output. Was that your intent (it will show up as e-mail to root
? Or did you just not show us the entire command?