Jump to content

Archived

This topic is now archived and is closed to further replies.

JayDz

PHP Cron job timer

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!

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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