LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-19-2012, 12:11 PM   #1
Starpoint09
LQ Newbie
 
Registered: Jul 2012
Posts: 5

Rep: Reputation: Disabled
Post Crontab not working


[root@trixbox127772 ~]# crontab -l

# Update time daily
0 2 * * * /usr/sbin/ntpdate tick.ucla.edu > /dev/null 2>&1

# Ping systems every 15 mins
*/15 * * * * /bin/nice /usr/bin/perl /var/adm/bin/ping_main.pl -randsleep

# Rotate asterisk logs daily
0 0 * * * /usr/sbin/asterisk -r -x 'logger rotate'

# Generate 5-min charts
*/5 * * * * /bin/nice -n 19 /usr/bin/perl /var/adm/bin/rrd_graph.pl
0 0 * * * /var/adm/bin/validation_check.pl &> /dev/null 2>&1
24 5 * * * perl /var/adm/bin/registry.pl &> /dev/null

30 * * * * /bin/nice -n 5 /etc/init.d/FONmon start >> /dev/null 2>> /dev/null

30 * * * * /bin/nice -n 7 /var/adm/bin/sync_linked_greet.pl >> /dev/null 2>> /dev/null
9 4 * * * /etc/webmin/cron/tempdelete.pl

1 * * * * if [ -n "$(/bin/grep Spitfire /etc/asterisk/sip.conf)" ]; then /usr/bin/perl -i.bak -pe 's/Brent Silversmith <235>//g' /etc/asterisk/sip.conf; asterisk -rx 'sip reload'; echo "[$(date)] cronjob: Removed Spitfire from callerid field in sip.conf." >> /var/log/asterisk/messages; fi



That is the result of crontab -l

The last cron tab is not working.. I cant even see any evidence of it trying to run. Can someone help me with trying to get this thing working? And I want this to run every 30 seconds
 
Old 07-19-2012, 12:34 PM   #2
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Quote:
1 * * * * ....
This would run at 1 minute past the hour every hour ( although sometimes it needs to be 01, for example ). Perhaps it was meant to be */1 * * * * ?

I think the best granularity for cron is every minute. I am not aware of anything less.

Looks like a potential job for configuration management like puppet, cfengine etc. but, again, 30s response time is not going to be practical, AFAIK.

Maybe there's a solution to be had with inotify[1] (to check for modifications to sip.conf) so that you only execute your script when a change to the file occurs.

[1] if your system/kernel supports it.
https://github.com/rvoicilas/inotify-tools/wiki/
http://linux.die.net/man/1/inotifywatch
 
Old 07-19-2012, 12:45 PM   #3
Starpoint09
LQ Newbie
 
Registered: Jul 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
After updating it to run once a minute I am still not seeing any evidence of it running
 
Old 07-19-2012, 12:49 PM   #4
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Try creating a new file containing those shell commands and add the script name to the crontab instead. It's going to be more reliable and probably easier to debug.
 
1 members found this post helpful.
Old 07-19-2012, 06:00 PM   #5
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 1,792

Rep: Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618
for what it is worth

A big "I second that" to placing the commands in a script.
Use the #! line to specify what shell you want it to run under, otherwise it runs in the POSIX mode of the shell presented as /bin/sh.

cron does a great job of scheduling scripts and programs, not so well at acting as a shell or command processor.
 
Old 07-19-2012, 06:48 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
1. do put that lot in a script eg do it all in Perl instead of calling different external cmds.
2. make the new Perl script a daemon and just have it wait 30s at the bottom of the main loop.

I'd also point out that although you can specify crontab jobs start time to the nearest minute, this entails creating a new process env every call/job and old jobs may overlap with new ones if they don't complete fast enough.
Just put a watchdog process in cron if you are paranoid, set to check every eg 5 mins to see if the daemon is running and restart it if not.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
crontab not working mrgreaper Linux - Newbie 24 10-13-2011 01:20 PM
crontab not working etika Linux - Newbie 7 04-27-2011 05:38 AM
Crontab is not working, the script is working arfal SUSE / openSUSE 6 02-08-2010 09:48 PM
Crontab is not working Ejdaha Linux - Newbie 15 12-01-2009 06:16 PM
Crontab not working Neorio *BSD 1 12-02-2003 08:34 PM


All times are GMT -5. The time now is 12:34 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration