I want to use cron to hourly run a python program in Linux(ubuntu). I wrote a script called script.sh
cd Dropbox/NetworkProject/AMT_Crawler/
scrapy crawl AmtCrawler --set FEED_URI=data.json --set FEED_FORMAT=json
Then I used
crontab -e
and add a line like this
*/30 * * * * sh Dropbox/NetworkProject/AMT_Crawler/script.sh 2>&1 >> /Dropbox/NetworkProject/AMT_Crawler/output.log
After this, I run
sudo /etc/init.d/cron start
in terminal. It said
Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service cron start Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the start(8) utility, e.g. start cron
So I run this
service cron start
Then there was an error:
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.196" (uid=1000 pid=12574 comm="start cron ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Now I'm stuck with this problem asking for some help.
sudo– RC. Nov 7 '11 at 5:55script.shhas execute permission (chmod +x script.sh), then theshshould be unnecessary (but harmless). – Keith Thompson Nov 8 '11 at 0:10