Re: OT. Cron jobs



On 3/10/07, Mike Blezien <mickalo@xxxxxxxxxxxxxxx> wrote:
Hello,

Sorry for the OT question, but couldn't find the info I was looking for and
thought could get a quick answer from the list.

We have a perl script that needs to run 4 times a minute. Can this be done via
cron or is there an easier way to do this within the Perl script itself? This 4
times a minute every day.

Cron can only handle a resolution of one minute, but you can use sleep
along with four jobs to achieve the effect you desire:

cowens@putain:~$ crontab -l
* * * * * echo -n "1:" >> /home/cowens/log.txt; date >> /home/cowens/log.txt
* * * * * sleep 15; echo -n "2:" >> /home/cowens/log.txt; date >>
/home/cowens/log.txt
* * * * * sleep 30; echo -n "3:" >> /home/cowens/log.txt; date >>
/home/cowens/log.txt
* * * * * sleep 45; echo -n "4:" >> /home/cowens/log.txt; date >>
/home/cowens/log.txt
cowens@putain:~$ tail -f log.txt
1:Sat Mar 10 21:17:01 EST 2007
2:Sat Mar 10 21:17:16 EST 2007
3:Sat Mar 10 21:17:31 EST 2007
4:Sat Mar 10 21:17:46 EST 2007
1:Sat Mar 10 21:18:01 EST 2007
2:Sat Mar 10 21:18:16 EST 2007

This is still not an ideal solution though, since two copies of a
script can be running concurrently if the script takes more than 15
seconds to run. For some scripts this is not an issue, but others
have issues with that. In those cases a better scheduler than cron is
required. You could also change the script into a daemon.
.



Relevant Pages

  • [NEWS] IBM Informix Web DataBlade Local Root by Design
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... that ease development of "intelligent", interactive, Web-enabled database ... person who has access to change the Perl script. ...
    (Securiteam)
  • my perl script for ripping mp3s...aka MP3scRIPt
    ... This is a Perl script to convert audio cd tracks to mp3s. ... Possibly root privs to access the cdrom device ... - this is mainly a problem on 'variety cds', mp3 files suffering from this ill ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Perl script to mimic uniq
    ... mdfoster44@netscape.net spits TOFU in my face: ... > # Perl script to find most common CS ... > So I'm back to my original script which looks like this. ... > identify a sequence as unique. ...
    (comp.lang.perl)
  • Re: Slow Performance When Using DBI, otherwise Not
    ... If I run the same perl script on the database server itself it runs ... check versions of DBI and DBD (I greped for version on every module under ...
    (perl.dbi.users)
  • RE: I have a weird issue with a script running under cron
    ... cron does not run your ".profile". ... It might be crazy to ask whether you have explicitly executed your ".profile" before invoking your Perl script. ... script to see which libraries aren't resolving would be a useful test: ...
    (perl.dbi.users)