script in cron.hourly not running hourly
I've put a file called 'test' in /etc/cron.hourly. Its code is:
Here is my crontab (I dont understand this file, even after reading the man pages)
# /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.
# This file also has a username field, that none of the other crontabs do.
# m h dom mon dow user command
17 * * * * root run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6 * * 7 root test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6 1 * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
Make sure your file /etc/cron.hourly/test is executable and has the shebang line (#!/bin/bash):
Cron [at least the one which comes with Unbuntu] works out if there have been changes to the exitsing jobs by checking the timestamp on some directories. Check that the /etc/cron* stuff doesn't have screwy timestamps.
Make sure touch is in the PATH which is specified in your /etc/crontab, or modify your test script to speciy the full path to touch. The biggest cause of problems with cron jobs is that people assume they run with the same environment variables as their shell, and this is not true - cron jobs get a very "naked" environment, which may cause some programs to not be found, or not function as expected.
That's all I can think of right now.
Thanks for that informative post! I understand the crontab file better now. It turns out that the problem with my file was that it didn't have the 'shebang' line :)
Thanks again for your help. There are a lot of things I want to schedule on my kubuntu machine.
|All times are GMT -5. The time now is 11:36 PM.|