user2710234
user2710234

Reputation: 3225

Running PHP File on a Cronjob in cPanel

I have a file called automate.php with a mysql connection string and a few PHP/SQL Queries and I want to run the file on a Cronjob.

I have tried just using the full URL like:

http://www.domain.com/script.php

the local path:

/home/your_username/public_html/script.php

and also:

php -f -q /home/your_username/public_html/script.php

i get an email every time it is run and its just saying: No input file specified.

what am i doing wrong?

Upvotes: 3

Views: 8191

Answers (5)

Waruna Manjula
Waruna Manjula

Reputation: 3477

use this command

php-cli script.php

Upvotes: 0

Ray S.
Ray S.

Reputation: 1200

if wget does not work try

curl "http://url.com/script.php"

instead of

wget http://url.com/script.php

Upvotes: 0

Explosion Pills
Explosion Pills

Reputation: 191729

It sounds like a permissions issue. Make sure that the cron runner user has executable permissions on this php file. Also make the file executable:

chmod +x /path/to/script.php

At the top of the file add:

#! /usr/bin/env php

Now the script should be able to run on its own:

*/5 * * * * /path/to/script.php

Upvotes: 3

eddy52
eddy52

Reputation: 1

you should have your server domain + your script path i.e. http://server.domain.net/myscriptfolder/script.php which is http://server.domain.net absolut domain of your hosting/domain provider. In my case this works...

Upvotes: 0

Shakti Patel
Shakti Patel

Reputation: 3862

use this command

for every 5 minite

*/5 * * * * wget http://www.domain.com/script.php

Upvotes: 3

Related Questions