Saturday, October 11, 2014

Using Cron Job to process PHP scripts




Using Cron Job to process PHP scripts.
For example, we have test.php and want to run it  every day using cron job.
1) test.php
<?php
    echo '<h1> This is  a test for cron job</h1>';
?>

 2) Create a shell script test.sh
#! /bin/sh
#wget -q --no-check-certificate -O- "http://swf.site40.net/crontest/test.php"
php test.php
3) run following in shell to make test.sh executable
chmod +x test.sh
4)  The reason we want to use php instead of wget is that we do want outside people access test.php
Set up .htaccess to Deny from all in the directory of test.sh
<Files "*">
    Order deny, allow
    Deny from all
</Files>

5) crontab -e
30 23 * * * /home/jiansenl/crontest/test.sh
each night 23:30pm to  run test.sh
6) crontab -l
list cron jobs.
Video: Using Cron Job to process PHP scripts

2 comments:

  1. hello. thanks for the article.
    i have tried this on a suse leap 42 without sucess.

    php gives me error
    im trying to read a php page wich reads a series of parameters and stores them to a mysql db.

    ReplyDelete
  2. Hello
    We are professional traders, earning on forex and binary for investors weekly, will love to tell you all more about our investment platform where you can invest funds as little as $200 and start earning $2500 weekly, alot of people has benefited from this investment offer before and during this convid-19 virus, if you passing through financial difficulties due to this coronavirus and you need help paying bills simply choose a suitable investment plan for yourself and start making profit weekly

    $500 to earn $5,000 in 7 days
    $1000 to earn $10000 in 7 days
    $5000 to earn $50000 in 7 days

    To Start your investment now contact Via whatsapp: (+12166263236)
    email: carlose78910@gmail.com

    ReplyDelete