LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-26-2009, 06:49 PM   #1
majorlinux
LQ Newbie
 
Registered: Dec 2007
Location: Greensboro, NC
Distribution: Fedora
Posts: 8

Rep: Reputation: 0
Faster than Crontab


Is there anything faster than crontab? I am working on a project and need crontab to run faster than it currently does. Is that possible or is there software I can install to get it to do that?
 
Old 03-26-2009, 07:44 PM   #2
watcher69b
Member
 
Registered: Nov 2007
Location: /home/watcher69b
Distribution: RH, Fedora & CentOS
Posts: 552

Rep: Reputation: 41
what do you mean 'faster'?
 
Old 03-27-2009, 09:28 AM   #3
majorlinux
LQ Newbie
 
Registered: Dec 2007
Location: Greensboro, NC
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
I need something that will run more often than a minute.
 
Old 03-28-2009, 01:20 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,238

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
My rule of thumb is that its a waste of resources to ask cron to keep initialising new processes more than every 5 mins. There's quite an overhead, it has to create a whole new proc env every time.
Use a daemon containing infinite loop and wait as long or short as reqd at the bottom of the loop.
 
Old 03-28-2009, 02:13 AM   #5
majorlinux
LQ Newbie
 
Registered: Dec 2007
Location: Greensboro, NC
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
My rule of thumb is that its a waste of resources to ask cron to keep initialising new processes more than every 5 mins. There's quite an overhead, it has to create a whole new proc env every time.
Use a daemon containing infinite loop and wait as long or short as reqd at the bottom of the loop.
Can you give me an example of that?
 
Old 03-28-2009, 07:54 AM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Code:
#!/bin/bash
while [ 1 ]
   do
   /path/to/your/program
   sleep 20
done
jlinkels
 
Old 03-28-2009, 09:17 AM   #7
majorlinux
LQ Newbie
 
Registered: Dec 2007
Location: Greensboro, NC
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlinkels View Post
Code:
#!/bin/bash
while [ 1 ]
   do
   /path/to/your/program
   sleep 20
done
jlinkels
So does that sleep it from 20 seconds or 20 minutes? I'm assuming seconds.
 
Old 03-28-2009, 12:13 PM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian 11
Posts: 6,135

Rep: Reputation: 420Reputation: 420Reputation: 420Reputation: 420Reputation: 420
From man sleep:
Code:
SYNOPSIS
       sleep NUMBER[SUFFIX]...
       sleep OPTION

DESCRIPTION
       Pause  for  NUMBER  seconds.  SUFFIX may be s for seconds (the default), m for minutes, h for hours or d for
       days.  Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point
       number.  Given two or more arguments, pause for the amount of time specified by the sum of their values.
 
Old 03-28-2009, 12:20 PM   #9
majorlinux
LQ Newbie
 
Registered: Dec 2007
Location: Greensboro, NC
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by tredegar View Post
From man sleep:
Code:
SYNOPSIS
       sleep NUMBER[SUFFIX]...
       sleep OPTION

DESCRIPTION
       Pause  for  NUMBER  seconds.  SUFFIX may be s for seconds (the default), m for minutes, h for hours or d for
       days.  Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point
       number.  Given two or more arguments, pause for the amount of time specified by the sum of their values.
Cool...cool...Thanks
 
Old 03-28-2009, 12:46 PM   #10
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by majorlinux View Post
So does that sleep it from 20 seconds or 20 minutes?
20 hours.

If you are too lazy to read the manual page or to check the TLDP website I am sorry to have put in my time to help you.

jlinkels
 
Old 03-28-2009, 12:48 PM   #11
majorlinux
LQ Newbie
 
Registered: Dec 2007
Location: Greensboro, NC
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlinkels View Post
20 hours.

If you are too lazy to read the manual page or to check the TLDP website I am sorry to have put in my time to help you.

jlinkels
I mean, I only asked because I'm not at the server right now. So many angry people...
 
Old 03-28-2009, 01:04 PM   #12
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian 11
Posts: 6,135

Rep: Reputation: 420Reputation: 420Reputation: 420Reputation: 420Reputation: 420
Please calm down.
It's worth remembering that the interweb knows almost everything there is to know about, including man pages. Eg here:
http://linux.die.net/man/
They come nicely formatted too
 
Old 03-28-2009, 01:32 PM   #13
robel
Member
 
Registered: Oct 2008
Location: Norway
Distribution: Slackware
Posts: 77

Rep: Reputation: 19
Quote:
Originally Posted by jlinkels View Post
Code:
#!/bin/bash
while [ 1 ]
   do
   /path/to/your/program
   sleep 20
done
Nice, but what if you want this, like the subject says, to be like cron? I mean, what if you want the program to be run at 00:00:00, then at 00:00:20, then at 00:00:40, then at 00:01:00, then at 00:01:20, and so on.

Now, add the fact that 'program' runs between 1 and 10 seconds so a simple 'sleep' would not do the trick. You would like a 'sleep 20 sec measured from the previous sleep including running time of the program'.

'program' can look like this:

Code:
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

int main (void)
{
    srandom(time(NULL));
    sleep((int)(10*(double)rand()/RAND_MAX));
    return 0;
}
Guess you can use 'time' and measure the time spent in 'program', and then figure out how long the sleep will be.

-Bob-
 
Old 03-28-2009, 03:47 PM   #14
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Look at this post of mine:
http://www.linuxquestions.org/questi...-timer-714154/

But there is a syntax error in my code, it was corrected in the succeeding post.

jlinkels
 
  


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
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
LXer: Firefox 3 Beta 4 is 5x faster than IE7, 3x faster than FF2 LXer Syndicated Linux News 0 03-12-2008 05:50 PM
DISCUSSION: Faster and Faster Compilation jeremy LinuxAnswers Discussion 5 12-06-2005 01:41 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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