Linux Mint 15

I'm trying to run this small script located in /etc/cron.hourly/ in order to learn how to use cron but it's not running, any ideas? And the "test" script in this case has already been set to executable.

garrett@garrett-bedroom /etc/cron.hourly $ cat test
touch /home/garrett/Desktop/CRONTABWORKED!.txt

Recommended Answers

All 6 Replies

Who owns the script, does it need to be run as root and if so have you set it up under the Root Cron Daemon?
Can you execute the script manually?

Show the contents of the crontab itself. The script is one thing. The crontab is another.


Your missing a few things in your crontab file. Simply placing the file in /etc/cron.hourly is not enough. The format of an entry in a crontab file is like this sample file. Lines that start with a # are comments and ignored by cron:

     # use /bin/sh to run commands, overriding the default set by cron
     # mail any output to `paul', no matter whose crontab this is
     # run five minutes after midnight, every day
     5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
     # run at 2:15pm on the first of every month -- output mailed to paul
     15 14 1 * *     $HOME/bin/monthly
     # run at 10 pm on weekdays, annoy Joe
     0 22 * * 1-5    mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
     23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
     5 4 * * sun     echo "run at 5 after 4 every sunday"

The easiest way to create a crontab file is while logged in to a shell as garrett type the following:

crontab -e

To see your crontab use:

crontab -l

To remove the current crontab for the user:

crontab -r

Hope this helps. retracted...

rch1231, thanks for you detailed response. What I actually ended up doing to get it to work was simply placing #!/bin/bash at the top and making it executable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.