Hi there
Fairly new to php, with an unusual question (?)
I have a task that I want to carry out, at certain intervals. Currently it have cron set to do it every minute/2 minutes a I wish (though I do find it a pain going in to cPanel to edit the cron job every time I want to change it.
What I would like ot do is come up with an alternative.
I have been looking at the possiblility of using the sleep() function where the value in seconds could range anywhere from 10 seconds to 90. I intend to do this until the number of executions of the task reaches a certain number (50 or 100 ish).
Now, couple of questions. I am currently testing this function by sending an email as my task to execute, and running it from a browser. For testing purposes, I set the sleep (2) and use a for loop to run until executions is equal to 5. This works, I get five emails.
If I increase the value of sleep () to (60), the browser times out (as I would expect) and I only get 1 email. How can I run this script so it contiunues to run on the server? (Is this possible?) Can I start this script from another page in a browser window so that it will continue to run until count reaches its target?
Will this have any effect on CPU usage, I read that sleep passes CPU to other processes, will this be OK on server load?
I know this may not be clear, but I'm new to this, and playing with things I may not understand too much and may be hoping for too much from.
Hopefully it will prove an interesting outcome, but who knows.
Oh, and the reason to use sleep is to enable the frequency of the execution to be modified without affecting the cron, and to allow more flexibility than cron.
Many thanks in advance.
Irregular scheduling job questions
Moderator: General Moderators
-
chinesewhispers
- Forum Newbie
- Posts: 2
- Joined: Sun Mar 20, 2005 6:17 pm
-
chinesewhispers
- Forum Newbie
- Posts: 2
- Joined: Sun Mar 20, 2005 6:17 pm
I think this will do.
Use a crontab of 1 minute on a script. This script will just check if the time for the execution of the other srcipt is up and calls it if necessary.
This check can be a db or file driven var or any other means to determine if the script needs executing and how many times it should execute.
The problem is that cron is just minutewise. To do it in seconds you would probably have to program a demon that runs indefinately.
Use a crontab of 1 minute on a script. This script will just check if the time for the execution of the other srcipt is up and calls it if necessary.
This check can be a db or file driven var or any other means to determine if the script needs executing and how many times it should execute.
The problem is that cron is just minutewise. To do it in seconds you would probably have to program a demon that runs indefinately.
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland