Jump to content

PHP Cron job timer


JayDz

Recommended Posts

Hallo!

Ik heb net een cron job ingesteld via cpanel.
Graag zou ik via php een timer willen hebben om te laten zien hoelang het duurt voordat de cronjob opnieuw word uitgevoerd.
Ik heb gegoogled maar kon hier jammergenoeg niets over vinden.
Heeft iemand van jullie een idee?

Thanks!

Link to comment
Share on other sites

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
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
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
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.