Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

though many of us has asked many question related to cron jobs, let me ask my one...

I want to execute a PHP script periodically. As a cron command I'm using:

php -q

I also tried this one:

php -q /home/myuser/

It is not getting executed and not sending any mail. I set the mail ID to my gMail ID. What am I doing wrong?

share|improve this question
If you execute the script directly is the mail sent? – Jane T Apr 21 '11 at 15:27
In CPanel there is an option to set an email id. Send an email every time a cron job runs. less » You can have cron send an email everytime it runs a command. If you do not want an email to be sent for an individual cron job you can redirect the command's output to /dev/null like this: mycommand >/dev/null 2>&1 Current Email: – Abhishek Apr 21 '11 at 15:44

What you are attempting will not work as you cannot pass GET variables via the PHP command line and you need to either escape question marks or surround the string with quotes when using question marks on the command line.

This will work:

wget ''

share|improve this answer

How about:


are you sure you have as your path?

execute the following in your cron.php

// current directory
echo getcwd() . "\n";

This will return you the exact directory where your cron.php file is located, and the use php -q in your cron.

I think you should use something as this on cPanel:

php -q /home/myuser/public_html/cron.php?action=getA
share|improve this answer
I have tried "wget"; this one also. But no mails. :( – Abhishek Apr 21 '11 at 15:54
Execute the line to get the folder path. And then include it with PHP -q – Adnan Apr 21 '11 at 15:57
u meant to say "php -q /home/myuser/pathtocronfile/cron.php"? I tried that. :( Please elaborately reply. – Abhishek Apr 21 '11 at 16:10
As cron commands i tried this one: wget /home/myuser/public_html/cron.php; php -q /home/ovsec/public_html/cron.php it is not working. Please help. – Abhishek Apr 21 '11 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .