cron problems


 
Thread Tools Search this Thread
# 1  
cron problems

I am trying to setup a cron that runs a script to update my ip for my domain name every time I reboot and checks if my ip changes every 5 minutes and if it does then I update it. I am running Ubuntu server 12.04.

The file /etc/cron.d/ipupdate contains
Code:
# 
#  
#  Run ipupdate
#  

# 
/5 *     * * *     root         /usr/local/bin/ipupdate
@reboot            root         /usr/local/bin/ipupdate

The file /usr/local/bin/ipupdate contains
Code:
#
#Script to enable dynamic IP
#
if [ `ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` != `cat /usr/local/bin/ipchange` ]
then
wget -q -O /dev/null http://freedns.afraid.org/dynamic/update.php?_USERSPECIFIC_
ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' > /usr/local/bin/ipchange
echo `date` IP updated to `cat /usr/local/bin/ipchange` >> /home/foo/log
fi
echo `date` IP update finished running >> /home/foo/log

and the /etc/cron.d/ipchange just contains the ip from the last change.

All the above files have been set to give permission to all users (chmod 777) and when I run the script with /usr/local/bin/ipupdate it works how I want it to.
# 2  
first thing to try when cron is misbehaving is to provide a full pathname to any executables, eg /sbin/ifconfig
This User Gave Thanks to Skrynesaver For This Post:
# 3  
What is in /home/foo/log? The last line of your script should always update that file, even if the if block doesn't execute.

If that log doesn't get updated, it's probably a permission problem.
This User Gave Thanks to ThomasMcA For This Post:
# 4  
Fixed

It is working now. I think the problem was that the change file did not belong to the root user.

Thanks for all the help
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #811
Difficulty: Easy
RGBA stands for red green blue alpha.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problems with set up Cron

Hi I want to set up a cron for every 15 minutes between some hours. Can you tell whether the below command will work. Getting confuse because my time goes from night to next day morning. i want to setup 8 PM to next day 10 AM. */15 20-10 * * * sh abc.sh (1 Reply)
Discussion started by: raju2016
1 Replies

2. UNIX for Dummies Questions & Answers

Execution Problems with Cron

Good evening, ive got this cron to be run: if i run this manually it doesnt work,it takes me to the prompt again /export/app/CO/opge/scr/Informe_parametros_colombia.ksh >/dev/null 2>&1 here is the code fragment: coopge@coopge: opge PRODUCCION>more... (1 Reply)
Discussion started by: alexcol
1 Replies

3. UNIX for Dummies Questions & Answers

Execution Problems with Cron

Hi friends, today i created a cron job , registered the crontab file associated but dont know why the cron is not getting executed at the right time.?? content of Crontab file : 21 15 * * * /subrat/myt i wanted to execute the script myt on 15:21 PM of everyday. the script myt... (2 Replies)
Discussion started by: paras.oriental
2 Replies

4. Shell Programming and Scripting

Execution Problems with Cron

Hi, I have written a shell script to transfer files to a SFTP server passing the filername, source and dest directory as parameters and it runs well. :) I want to schedule this script to run periodically using a cron job. root@pingu # cat /etc/crontab SHELL=/bin/bash... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

5. Programming

execution problems with cron

how to store a date into file? and how we can access date from the file? ---------- Post updated at 06:09 AM ---------- Previous update was at 06:08 AM ---------- how we can store date in file? (1 Reply)
Discussion started by: causalmodi777
1 Replies

6. Shell Programming and Scripting

Problems with Cron and isql

Dear Friends, I am running a script which runs a select query from a sybase table and outputs the result (1 row) into a .txt file in unix. When I run the script manually it behaves normally. However it doesnt run in crontab. #!/usr/bin/ksh . /opt/ivb/config/set_env ... (1 Reply)
Discussion started by: santoshpayal
1 Replies

7. UNIX for Dummies Questions & Answers

Problems with script and Cron

Hi Guys, total newbie here, Ive read through some of the threads about cron and scripts not working and have still drawn a blank as to why mine isnt working correctly. I have a script that runs the ausearch with a set of criteria i have setup, the only access i have to the system is via... (5 Replies)
Discussion started by: richie190784
5 Replies

8. UNIX for Dummies Questions & Answers

Problems using rsync with cron

Hi, I've created a cron job for a script with a rsync command in it. The script is named pull.sh and contains the following line : What it is supposed to do is pull backup files from the production server of my company to my local server. It should also generate the log file (output.log)... (1 Reply)
Discussion started by: anaigini45
1 Replies

9. UNIX for Dummies Questions & Answers

cron problems

Hi there, this time a have a other problem :) i will start a script over the cron. if i start the script manual (per command) it works without any problems, but over the cron it doesent work. my cron looks like this: 26 15 * * * /path/scriptname.sh 2> /path/error.log there is no... (3 Replies)
Discussion started by: scotty
3 Replies

10. UNIX for Advanced & Expert Users

Cron problems

Hi, I am having a few problems with cron. I have created a shell script (to rotate www logs - this works) and then did the following (as root) #crontab -e 2 0 * * 3 /cron_scripts/wwwlogs.sh ? w ? q # crontab -l entry not shown e.g. it did not show what I had just writern I then... (6 Replies)
Discussion started by: warrend
6 Replies

Featured Tech Videos