1
votes

How to use php file for my cron job after every minute in cpanel.

I have my file under public_html folder.

Searching over google I pass the following path in command text box.

/home/addrej/public_html/abc.php

================

SOLVED

I need to write php -q /home/addrej/public_html/abc.php

2
thats ok, whats the problem?Alireza Fallah
file is not running.And I dont have my email account for this cpanel so I can't check email.I am performing some db operations and those are not working.But when I am running file as abc.com/abc.php its workinguser3110655
do you did exactly what I mention in my answer?Alireza Fallah
do you have ssh access to server to check weather command is working or not?Alireza Fallah
@AlirezaFallah sorry frend I do not get what do you mean ??? and how can I check whether cron is working or notuser3110655

2 Answers

0
votes

I have no idea how you managed to find the path of a file on your server by searching Google. I suspect the value you're using could be wrong. One way of getting this information is by uploading the following script to your site (call it whereami.php, for example) and accessing it with a web browser (at yoursite.com/whereami.php):

<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>

To run a PHP script from the command line (or a cron job), you need to know where your PHP application is located. /usr/bin/php is usually a safe bet, but your web host will be able to tell you. Pass the script you want to run as a command line argument, e.g.:

/usr/bin/php /path/to/my/html_docs/abc.php >/dev/null

The >/dev/null at the end of this line simply discards the output of the PHP script so it isn't emailed to you every time.

Another approach (and one I would actually recommend) is to get your web server involved. That way you can ensure that the script is run in exactly the same environment as the PHP scripts in your website. For example, using the curl utility:

/usr/bin/curl http://yoursite.com/abc.php >/dev/null
0
votes

You must use /usr/bin/php /home/YourCpanelUsername/public_html/abc.php

as cron job command instead of :

/home/addrej/public_html/abc.php