Auto Execution of PHP Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

Auto Execution of PHP Code

Post by waqas_punjabian »

Hi everyone here,

i am working on a job portal, here i want a functionality,

My php code should send jobs as an email to the registered users AUTOMATICALLY at every weekend.

How can i do that ?

thanks n regards

WAQAS
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

manjeet
Forum Newbie
Posts: 2
Joined: Thu Apr 27, 2006 12:38 pm
Contact:

Scheduling jobs

Post by manjeet »

hi , Scheduling can be done using cron job ...


create a file like task_schedular.php
list all the processes to be executed in this file

add this file to the cron job
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

First create the email sending script and put somewhere ex : /var/www/html/send_email.php

* * * * * command_to_be_executed
| | | | |
| | | | |_ day of the week (0-6)
| | | |__ month(1-12)
| | |____ day of the month(1-31)
| |______ hour(0-23)
|________ minute(0-59)

To add the cron job just go to terminal and use following command :

Code: Select all

#crontab -e
After that add the following line if you wish to send email at 11pm every night :

Code: Select all

0 23 * * * /usr/bin/php -q /var/www/html/send_email.php
Hope this might help in some extent.


:)

Cheers,
Dibyendra
Post Reply