I am new to cron. I learned some of the basics of cron. I can call php using the cron tab. Using the following command in / etc / crontab
10 * * * * root /usr/bin/php /var/www/PATH TO SCRIPT/email.php
In email.php I have the following code
#!/usr/bin/php <?php mail (" examplemail@mail.com ", "Cron Successful Public HTML!","Hello World from mycron.php!"); ?>
For every 10 minutes I get mail. But I need to know if there is a way to invoke the cron job from php (invoke cron from php) I get some idea while surfing, but I am not able to figure out how to exactly do my job. Here is the code I used to add the job using php
exec('echo -e "crontab -e \n2 * * * * /usr/bin/php /var/www/PATH TO THE SCRIPT/crontest1.php" ');
It does not work for me. can anyone tell me how to call or add cron from php. so that I can send mail by executing a php file and I can change the time interval in the php file itself.
suganya
source share