LinuxQuestions.org
Help answer threads with 0 replies.
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 12-11-2006, 08:05 AM   #1
meniscus
Member
 
Registered: May 2006
Posts: 70

Rep: Reputation: 15
editing crontab


The following code excecutes rrd_hddtemp.pl every 1 min




Code:
*/1 * * * * root /usr/local/bin/rrd_hddtemp.pl > /dev/null
Can i modify it to run every 1 sec?
 
Old 12-11-2006, 08:14 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
every second??? if you want to do someting once a second you are not doing it right... somethign runnign that fast needs to be programmed correctly. you realise that every time you run a cron job you start up a brand new environment, source profile configs and such, that's a massive overhead to do once a second and then through away... update your perl script to run as a loop or something. hddtemp sounds like a temperature related thing yeah? you really thing a harddrive can change it's temperature significantly once a second???
 
Old 12-11-2006, 08:32 AM   #3
meniscus
Member
 
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
Yes but ive edited that script to monitor CPU temperature 2. A CPU could burn up in 1 min if a fan failed or something couldnt it?

Every 10 secs then? It cant be that much load on the CPU can it?
 
Old 12-11-2006, 09:19 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
depends how well or badly written the script is... if a cpu is going to burn up within a minute, seems you'd need to also react to it even sooner don't you think? can you do anything within 10 seconds?

either way cron works on a per minute basis. by definition, if you need to do somethign mroe often, a generic extneral scheduler is not going to be a good way to do it.
 
Old 12-11-2006, 09:40 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
AFAIK, cron's smallest time unit is a minute. I wouldn't advise invoking running your perl program every second - this will start a new perl process and compile the script every execution, which is going to be horribly inefficient.

It would be much better to have a loop inside your script which does whatever it is you want to do, then sleeps for a second. For example:
Code:
#!/usr/bin/perl -w

use strict

while (1) {
    do_stuff();
    sleep 1;
} 

sub do_stuff {
    ...
}
If you're worried about such a program getting killed, you could have a cron job which tests if the program is running and re-launches it if necessary, or, if you have root access, have a respawn entry in your inittab file. Be very careful when putting stuff in inittab. You can make your system un-bootable if you mess this up.
 
Old 12-11-2006, 10:33 AM   #6
meniscus
Member
 
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
ok thanks. Ill steer clear of initab 2!
 
  


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 editing chobin SUSE / openSUSE 12 06-01-2006 11:12 AM
editing crontab mfran2002 Linux - Software 2 02-20-2006 08:09 AM
BASH :Reading the crontab, and editing it semaja2 Programming 4 02-05-2006 07:43 AM
editing crontab djgerbavore Slackware 12 05-30-2005 10:24 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 01:35 PM


All times are GMT -5. The time now is 12:01 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