0

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
#ENE#
5
Contributors
6
Replies
31
Views
4 Years
Discussion Span
Last Post by Spencer_1
0

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?

Edited by Octet

1

Hello

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
     SHELL=/bin/sh
     # mail any output to `paul', no matter whose crontab this is
     MAILTO=paul
     #
     # 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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.