Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a shellscript in /etc/myprog/ that I would like to run every week. Therefore I created a symbolic link in /etc/cron.weekly:

root@ip-10-190-199-197:/etc/cron.weekly# ls -ltr
total 8
-rwxr-xr-x 1 root root 895 2011-07-27 11:32 man-db
-rwxr-xr-x 1 root root 730 2011-09-24 14:55 apt-xapian-index
lrwxrwxrwx 1 root root  31 2011-11-17 05:36 myscript -> /etc/myprog/

To test it, I did:

cd /etc/cron.weekly
sudo ./myscript

It works perfect. However, the cronjob never actually runs for some reason. Do I need to do anything to activate cron.weekly?

The contents of my /etc/myprog/ is:

cd /var/log/myprog/
/etc/myprog/ 1> `date '+/etc/myprog/logs/%Y-%m-%d-cran.log'` 2> `date '+/etc/myprog/logs/%Y-%m-%d-cran-warnings.log'`
share|improve this question
Do you run the computer non-stop? Do anacron jobs run? Is the /etc/myprog/ file owned by root? Do you see any messages in syslog when the job is supposed to run? Have you tested running it hourly or some other time frame than weekly? – arrange Dec 31 '11 at 11:40
up vote 1 down vote accepted

I suspect you need to add a shebang to the start of your script to help cron know what interpreter to use. So your script would become:

cd /var/log/myprog/
/etc/myprog/ 1> `date '+/etc/myprog/logs/%Y-%m-%d-cran.log'` 2> `date '+/etc/myprog/logs/%Y-%m-%d-cran-warnings.log'`

Cron may not know much about paths and the like, so you need to give it more clues.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.