LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2009, 01:32 AM   #1
maxy7710
Member
 
Registered: Jan 2008
Location: Mumbai, india
Distribution: REDHAT, FEDORA,SUSE, UBUNTU, ORACLE ENTERPRISE LINUX & SOLARIS 10
Posts: 130

Rep: Reputation: 17
Unhappy cron not working


hi

my cron script is in /root/Scripts/NTP

vim /root/Scripts/NTP
ntpdate 172.17.124.15 >> /root/Scripts/ntp.log
----------------------------------------------------
crontab entries
*/2 * * * * sh /root/Scripts/NTP
----------------------------------------------------
tailf /var/log/cron | grep NTP
Mar 28 11:52:01 CPCAPP101 crond[9427]: (root) CMD (sh /root/Scripts/NTP)
Mar 28 11:54:01 CPCAPP101 crond[9442]: (root) CMD (sh /root/Scripts/NTP)
----------------------------------------------------

when i run the script as "sh /root/Scripts/NTP" then it runs perfectly
but in cron it some how doesn't work. "tailf /var/log/cron | grep NTP" shows cron job is been executed but in " /root/Scripts/ntp.log" i don't see the logs but when i run the script separately i get logs in "/root/Scripts/ntp.log"

Script is perfect & other cron jobs are working fine.
Only this particular script is giving problem.
 
Old 03-28-2009, 01:49 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
The only thing that comes to mind is permissions. cron is a bit fussy about what the exact permissions are. I've been bitten by this problem where something will run manually as a script but won't run in a cron context. Have you checked to make sure that NTP has the same permissions as the other scripts that do run successfully in cron have?
cheers,
jdk
 
Old 03-28-2009, 01:51 AM   #3
maxy7710
Member
 
Registered: Jan 2008
Location: Mumbai, india
Distribution: REDHAT, FEDORA,SUSE, UBUNTU, ORACLE ENTERPRISE LINUX & SOLARIS 10
Posts: 130

Original Poster
Rep: Reputation: 17
hi

this are the permissions & they are same

-rwxr-xr-x 1 root root 933 Mar 5 16:23 Graph
-rwxr-xr-x 1 root root 904 Mar 2 17:11 IO_Graph
-rwxr-xr-x 1 root root 292 Mar 2 17:12 Mem
-rwxr-xr-x 1 root root 94 Mar 28 10:57 NTP
-rwxr-xr-x 1 root root 756 Mar 28 12:12 ntp.log
 
Old 03-28-2009, 02:14 AM   #4
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Hi Maxy,
Hmmmmm. I just solved a problem with a script that I put in /etc/cron.hour. Since my isp changes the ip of the router regularly and I hate laptops I need to use ssh to access my system whenever I travel. So I needed a way of checking regularly to see if my routers ip had changed recently and if so then run a ddclient script to update my dynamic dns site. Just like your case, it didn't work from cron but if I ran the script manually it would work. Then I RTFM-ed the cron man page and found my script, called whatismyip.sh contained a full-stop (".") in the file name which is not allowed by cron. I removed the full-stop and now the script runs perfectly every hour and only runs the ddclient script when my router's ip has actually changed.

All this to say, your log file has a full-stop in the filename. It seems that should be ok but what if you changed the file name to ntp_log just to make sure that is not the problem.
cheers,
jdk

Last edited by jdkaye; 03-28-2009 at 02:16 AM.
 
Old 03-28-2009, 05:12 AM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
try
Code:
/usr/sbin/ntpdate 172.17.124.15 >> /root/Scripts/ntp.log
Cron needs the whole path.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working adnanm Linux - Software 3 07-24-2007 07:50 PM
cron.daily, cron.weekly not working mwhite74 Linux - Server 2 06-07-2007 09:51 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Cron not working robbiemorgan Linux - Newbie 6 09-16-2004 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration