Jump to content

Recommended Posts

Oh sorry, I tought this was a dutch forum somehow haha.

I just configured a cron job on the cpanel of my domain.
I would like to have a timer on a php page to see how long until the next cron job is executed.
I tried googling but couldn't really find anything.
Do any of you have an idea?

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/297745-php-cron-job-timer/#findComment-1518567
Share on other sites

You can use time or date right in a cron job command and then save it to a log, then you parse your log data.

 

I prefer to log something through the script itself.

You can do a start/end in the php script itself and log to a database. Two timestamps for instance, you know when it started and when it ended, you can do calculations on the timestamps and whatever cron periods you have the jobs set for.

If you need live data could poll the data with jquery or js/ajax

Link to comment
https://forums.phpfreaks.com/topic/297745-php-cron-job-timer/#findComment-1518584
Share on other sites

Unfortunately cron jobs are fairly archaic and opaque.  

 

You could create the illusion of a schedule in javascript and present countdown timers, so long as you either codify the cron schedule, or read it and parse it, however given the use of directories like cron.daily/weekly/hourly and the possibility of having many different users owning cron jobs, there is nothing out there that already does this for you that I am aware of.

 

If there are cronjobs installed you can get the raw crontab listing using:

 

 

crontab -l

 

But then you get something like this:

 

 

* * * * * /var/www/foo/utility/something.sh params

 

You'd be re-wrting the cron parser before you even began to figure out rendering a display and timers.

Link to comment
https://forums.phpfreaks.com/topic/297745-php-cron-job-timer/#findComment-1518607
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.