Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
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
#!/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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.