I want to create a cron job randomly once a day for my site's registration.
The responsible file for registrations is a config file and I need to change the contents
twice on day (on and off)
I know the way for random cron job for example
but i don't know how to change the values after one hour to normall (registrations off)..
Any suggestions on this>??
Sorry for my bad English
Thank you in advance
What OS do you have? -- simply using at will start a job, but you have to give it offset times, and those vary a little by OS. Plus you may have to edit files named like cron.deny or cron.allow depending on what you a really trying to do.
for openning registrations..But I need one cron job more to stop the previus (to change the config file again in normal mode after 1 hour--registrations off--)
I m trying with this php cron script but is not correct..Please help me with this script
<?
set_time_limit(0);
sleep(rand(0, 86400));
/*
my spesify code here
*/
?>
You can simply generate a random number each day (with one crontab file that runs only once at the beginning of the day) that corresponds to the number of minutes (or 5 minute intervals) each day, and write that number to a file.
Then, you have a second crontab file that reads the random number in the file and checks against the time and executes if there is match.
If you are using PHP, you can also try to use PHP shared memory, or you could use an environmental variable to hold the daily random number. There are many ways to do this.
---------- Post updated at 04:38 ---------- Previous update was at 04:34 ----------
While it is possible to set something up with the at command, the original poster asked for a crontab solution.
This is easily done with cron, as requested by the original poster.
What is the next crontab to check this file..I do not know..Which is the cron command to spy this file and calculate one hour????.Please give me an example..Thank you...