Cron Command not running

CranialBlaze

Expert Member
Joined
Jan 24, 2008
Messages
4,207
Reaction score
1,101
I have the following cron command setup, but for some reason its not running. Guess I am missing part of the execution command, but that what I run manually.

1 9 * * * ./reboot.exp

Its an autoexp script for restarting the router, have a stupid belkin that does not periodically update the dyndns with dyndns.com so when my IP does change I cannot remote access any of my home machines. Only way to update the ip is to restart the router, only then does it send the update.

IF anyone oculd help fix up that cron it would be greatly appreciated.
 
I have the following cron command setup, but for some reason its not running. Guess I am missing part of the execution command, but that what I run manually.

1 9 * * * ./reboot.exp

Its an autoexp script for restarting the router, have a stupid belkin that does not periodically update the dyndns with dyndns.com so when my IP does change I cannot remote access any of my home machines. Only way to update the ip is to restart the router, only then does it send the update.

IF anyone oculd help fix up that cron it would be greatly appreciated.

Have you made sure that the script runs when you start it manually?
 
Make sure you have made the script executable, and like mentioned put in the absolute path.

You should also check which user you are setting the cron for as if the script belongs to root you wont be able to run it as a normal user.
 
Make sure you have made the script executable, and like mentioned put in the absolute path.

You should also check which user you are setting the cron for as if the script belongs to root you wont be able to run it as a normal user.

It is executable, pretty much why I can execute it, everythings done with root, created another user with sudo but never bother using it. Too much effort.
 
Paths that don't start with a slash are always relative. Absolute path will start with a slash.
 
Let's start from the beginning:

1.) Distro?
2.) How did you create the cron job? What command did you use?
 
Common causes of non-working cron:
1. Full path to script was not used (./myscript vs /home/user/bin/myscript.sh)
2. PATH variable does not contain all the paths needed to run the commands.
3. User permissions on cron file is not correct (should be 600)

grep cron /var/log/messages, should provide you with some hint as to the problem.
 
Cron runs all scripts in a Bourne shell. Be aware for syntax purposes etc. it ignores any #! Directives...
 
I adjusted the path to /root/reboot.exp and that's not done anything, all other crons are working so it cannot be a permission problem with the cron file.

All 5 of the messages files contain variants of Jan 1 02:00:10 localhost kernel: [ 2.410327] usb 1-1.2: Manufacturer: JMicron
 
Can you provide the script you are running?
Have you tried redefining the PATH variable with all the directories you need to run the script?
Add "-x" to the shell at the top of the script, eg. #!/bin/bash -x
This might cause an email to be send with the verbose output.
You could also add the logger command in strategic parts of the script to see what is happening, for example:
Code:
<snip>
if [ $1 = "Yes" ]
then
    logger "$0 - Inside first if, we have a Yes"
    <some command>
else
    logger "$0 - Inside first if, we have a No"
    <some command>
fi
In the messages file you will then find entries that looks like:
<scriptname> - <message difined in script>
 
You should totally redirect stdout and stderr to a file...
 
I had a similar issue, use the full path to the script

i.e

1 9 * * * /path/to/script/reboot.exp

eg, if the script is in a scripts your home directory it would be

1 9 * * * /home/debonair/scripts/reboot.exp

and make sure that its executable
 
Top
Sign up to the MyBroadband newsletter
X