Linux - NewbieThis 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
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.
Just wondering, is there a command or utility out there anywhere which can output a countdown of upcoming jobs from crontab?
So you can display the queue of tasks in the order that they'll next run.
Anything like this out there?
EDIT: I realise there's crontab -l but that just echoes out the contents of the crontab file. I'd like somehow to get a countdown.
Just wondering, is there a command or utility out there anywhere which can output a countdown of upcoming jobs from crontab?
So you can display the queue of tasks in the order that they'll next run.
Anything like this out there?
EDIT: I realise there's crontab -l but that just echoes out the contents of the crontab file. I'd like somehow to get a countdown.
Cheers, B
The crontab file is the only evidence of job scheduling in the cron system. The cron utility reads the crontab files once every minute to see if any jobs are due to run. Therefore there is no system job queue for cron.
Your only option is to write a script to read the crontab files and create your own simulation of a job queue.
That's a shame, I just thought the OS would expose that info somewhere.
Don't think my bash scripting is up to that yet, might be able to knock something up in PHP though.
The problem I can see is if you use the */20 syntax to say eg: every 20 minutes.
Since it's not detailed in the crontab file at what point the first instance was run, so you don't know when the next 20 minutes starts/ends. Guess you'd have to parse the cron log for that to see what time that was last run.
In the meantime, I'll keep digging to see if someone's already been here!
The problem I can see is if you use the */20 syntax to say eg: every 20 minutes.
Since it's not detailed in the crontab file at what point the first instance was run, so you don't know when the next 20 minutes starts/ends. Guess you'd have to parse the cron log for that to see what time that was last run.
Well actually - it's not quite that complicated. In the
*/X notation it always starts counting from the 0th element;
so if you had
Code:
*/5 * * * * something
it would first execute at
the closest hour, then at the HH:05, then HH:10 and so
forth, not at some arbitrary value depending on when
you saved the crontab file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.