Abhishek
Abhishek

Reputation: 63

Cron job to execute a PHP program

I have a Linux server and in this I want to execute a cron job for sending birthday mail to all my friend with a PHP program. I want to create a php program that read data from database and send the mail.

I want to know the command of cron job to execute the program on every day automatically. I have no knowledge of Linux commands.

Upvotes: 0

Views: 5418

Answers (3)

Roloc
Roloc

Reputation: 1930

You will want to read up a little bit on the 'crontab' command but basically you will do this.

From a linux command prompt run the crontab command.

Then add this entry:

* * * * * php yourscript/path

You can set what time by modifying the * values. See this URL for information on that:

http://adminschoice.com/crontab-quick-reference

Upvotes: 3

Lukas Eder
Lukas Eder

Reputation: 220842

This is done using a cron table in unix systems, including linux. Check out some example documentation:

You'll find many more, if you google for crontab, or if you check out the man crontab pages on your linux box

Upvotes: 1

Dan Grossman
Dan Grossman

Reputation: 52372

This is the command to add to your crontab file:

0 0 * * * /usr/bin/php /path/to/your/script.php

Adjust the paths to the PHP interpreter and your script as necessary. It will run your script every day at midnight.

Upvotes: 2

Related Questions