Sell And Buy

Wednesday, 16 September 2015

How to execute a php file automatically on Server

Step1: Login to your Cpanel and find Cron job as shown in below.

Step2:Click on cron job and add below command on command box and set execution time according to your requirement.

php /home/USER/public_html/cron.php

Step3: Above command contains two part.

1.php which remains same.
2./home/USER/public_html/cron.php which will varry i.e write your program in a file i.e cron.php(any name with extension php)with following line

<?php echo "file path is:".$_SERVER["SCRIPT_FILENAME"]; ?>  

for getting complete path of file on server and run that file using your online domain name with your file, you get your  path. Just copy the path and add path with php to run the command automatically.

Step3: add (php path) in your command with time setting to execute a file automatically.

For more info mailus: