0

I was wondering how to make a php daemon script that runs one time at the day?

Do you know any good frameworks with benefits? or is it just small code?

Thanks

2
  • No need for a daemon for something that just runs daily. Commented Mar 26, 2012 at 16:33
  • You can use whatever code and framework you want to run a script on a schedule. But the scheduling part has nothing to do with that. Scheduling things is a basic function of any operating system. Please let us know your environment (unix/linux/windows/plan9/etc) so that we can post appropriate answers. Commented Mar 26, 2012 at 16:38

3 Answers 3

4

I was wondering how to make a php deamon script that runs one time at the day?

In order to do this, get familiar with cron jobs. A cron job is a function that gets executed by the server on a time interval. Usually you'd edit your "crontab" by executing crontab -e

Then, once inside, you'd write the interval you want, followed by the command.

Typically it looks like:

30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

Since its PHP, you can either a) run your php command as a php cli command, OR b) you can make the command get executed when a particular page is run... and just execute that in cron via a curl -X GET 'http://url/' (etc.)

Also, note that you can write all of your stuff in a shell script file and actually run that file as your cron command... that reduces line-item complexity

Sign up to request clarification or add additional context in comments.

Comments

3

cron

1 Comment

@Kolink, Links to Google searches are discouraged here. Can't you post a link to one of the better resources? Even the cron man page?
0

Sorry I haven't closed this one.

I actually discovered that my host didn't allowed cron jobs running. So I found a relevant homepage that offer a free service to make a request for me when I needed. In my case, I have specified a url link that should be requested to my RESTful API each day.

The link is here and works like a charm :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.