I would like to know if its possible to write a code in php similar to a cron script to run at a particular time when there is no traffic on site, that means i want the code to run without loading the site. Also I do not want to create a cron job on the server.
Asked
Active
Viewed 290 times
0
-
Yes, it is possible. But: __why?__ – Alma Do Dec 26 '13 at 08:04
-
yes you can but explain what you want actully. – rohitarora Dec 26 '13 at 08:05
-
@AlmaDo how is it possible. – Sarvesh Shejwadkar Dec 26 '13 at 09:33
-
@rohitarora - a cron to run at certain time, without the site being accessed – Sarvesh Shejwadkar Dec 26 '13 at 09:34
-
1possible duplicate of [How can I set cron job through PHP script](http://stackoverflow.com/questions/5134952/how-can-i-set-cron-job-through-php-script) – Jürgen Thelen Dec 26 '13 at 16:59
1 Answers
1
You can check if server is no too busy, run a cron job:
There's a function for that: http://www.php.net/manual/en/function.sys-getloadavg.php
example usage:
<?php
$maxLoad = 10; //set some number of max of processes in the system
$load = sys_getloadavg();
if ($maxLoad < $load[0]) {
//run a cron job
}

sergio
- 5,210
- 7
- 24
- 46
-
without loading a site means by not accessing it, by not running the site in the browser – Sarvesh Shejwadkar Dec 26 '13 at 09:37
-
-
well, i needed something like this http://stackoverflow.com/questions/5134952/how-can-i-set-cron-job-through-php-script – Sarvesh Shejwadkar Dec 26 '13 at 11:14