I've got a Debian VPS with a few websites on. I'm currently using django quite heavily.
I want a cron job to run and schedule a script inside one of my django sites. The upshot is that I can't get the Cron job running and I'm not sure how to sort it, as I've not got a lot of Linux experience.
my /etc/crontab file
# /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.
SHELL=/bin/sh
HOME=/home/shofty
LOGNAME=shofty
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/u开发者_JAVA百科sr/bin
MAILTO="info@webbricks.co.uk"
# 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 )
#
so I've set the job up in "crontab -e"
50 10 * * * /home/shofty/virtualenvs/webbricks/bin/chronograph -e /home/shofty/virrtualenvs/webbricks/bin/activate_this.py -p /home/shofty/virtualenvs/webbricks
but it doesn't appear to run at the time im trying for (10:50 is arbitrary, I'm adjusting it every few minutes to get it to run after changing a setting or another).
i think cron is running because i can do
/etc/init.d/cron stop
but the same command with a start fails. obviously witha start after to make it run again. from everything i've read, the output of a ps aux hints that it is running.
root@shoftys - server>_ /home/shofty# ps aux | grep cron
root 19106 0.0 0.0 18548 948 ? Ss 10:42 0:00 /usr/sbin/cron
root 27130 0.0 0.0 3876 600 pts/0 S+ 15:52 0:00 grep cron
I've added a > /home/shofty/virtualenvs/webbricks/cron.log to the command in crontab but it doesn't seem to want to output a logfile. and im getting absolutely nothing in /var/log/cron, it just says its a new file.
as a noob, im a bit unsure where to go next, would someone who knows a lot more about linux, debian and cron suggest where to look next please?
Its all much easier than that!
Revert all your changes to the crontab and instead add a link to your script in /etc/cron.daily or /etc/cron.hourly as required. How often would you like it to run? If more often or more precise times I can help you out there too. But if you just want a daily/hourly script to run, put it (or a link to it) in one of those directories.
If you want to control the specific time your script runs, better put it in crontab: 0 1 * * * username /path/to/my/script
You were just missing the username! When that happened your cron-tab would have looked wrong and that's why you weren't able to /etc/init.d/cron start again ;)
p.s to add a link into the cron.daily directory:
ln -s /path/to/my/script /etc/cron.daily/scriptname
精彩评论