When i run my url https://localhost/panel/index.php?m=user_games&p=check_expire by using chrome the code is run and shutting down the server when expier.
But when i need to run this as a crontab using this command:
* * * * * * wget -q --spider "https://localhost/panel/index.php?m=user_games&p=check_expire"
nothing happend, why?
Seem the crontab not run, because you define wrong crontab command. You put six *, as I know we just need five *. Please try like this
* * * * * wget -q --spider "https://localhost/panel/index.php?m=user_games&p=check_expire"
To make sure your crontab run, please create log when wget executed.
Related
I have good .php file when run directly via address bar browser.
But not process perfectly when run via cron job, may be it's just process first query msyql/first loop.
there is any special configuration for it?
My cron setup is
0 * * * * wget --spider -O - http://domain.com/cronjob >/dev/null 2>&1
See below example that is run your file on per minute
* * * * * /usr/bin/php /var/www/html/<your-file-name>
< and > are removed in <your-file-name>
I am pretty new to setting up cron jobs. What I've done so far is set one up to run every 5 minutes using the following script:
*/5 * * * * wget -q localhost:8888/example/index.php/controller/function
When I run just the wget part from the command line, it works perfectly. But in the crontab, while the logs show it being ran every 5 minutes, nothing is happening. Am I missing something easy? Any help is appreciated!
Thanks!
You can force a particular shell with
SHELL=bash
*/5 * etc...
or whatever in the crontab. Then make sure wget is available in that shell's path.
Otherwise just give an absolute /usr/bin/wget path instead.
*/5 * * * * /usr/bin/wget etc...
I want a script file to run once every minute.. I've written this command.
* * * * * php -q /home/<username>/public_html/cron.php
But, this cronjob is not working. whenever, I try to open this file cron.php in browser, it works fine.
I'm using Linux OS. Is there a way to debug it in order to come to know the error?
If you're using Ubuntu as I am, use the full path.
* * * * * /usr/bin/php -q /home/<username>/public_html/cron.php
Have you added an empty line (new line) after your cronjob?
To debug:
Append 2>&1 to the end of your Crontab command. This will redirect the stderr output to the stdout. Then ensure you're logging the crontab's Unix command.
* * * * * php -q /home/<username>/public_html/cron.php; ls -la >>/var/log/cronrun 2>&1
This will capture anything from the Unix command.
A couple of additional hints: Write out the environment variables by issuing the command set with no parameters. And get the shell to echo each command with the set -x command. At the top of your script issue;
set
set -x
For cPanel, you may want to test curl (in case it's installed on your server):
curl --silent --compressed http://www.your-domain.com/cron.php
So it should look similar to: http://grabilla.com/0450d-93d93a32-02ab-457c-ac1c-d2883552a940.html#
You may also want to try removing the -q from your command and see if it helps.
* * * * * php /home/<username>/public_html/cron.php
*/1 * * * * /usr/bin/php -q /home//public_html/cron.php
Add the above line to the crontab file and run it . It will add a cronjob every minute
Im running ubuntu server, and im trying to run a script every hour.
What I tried is:
sudo crontab -e
and then I add this to the end of the file:
MAILTO="info#email.com"
30 * * * * /usr/bin/php /var/www/scripts/cronscript.php
The script doesnt seem to be running, and im not getting the email.
What am I doing wrong?
Use the -f flag of php to tell it to take that file as input:
MAILTO="info#email.com"
30 * * * * /usr/bin/php -f /var/www/scripts/cronscript.php
That is, of course, if your php is actually located at /usr/bin
using:
30 * * * * /usr/bin/wget "http://example.com/scripts/cronscript.php"
worked for me
You can also use cURL, like this:
curl http://foobar.com/scripts/cronscript.php
If you need it to run silently:
curl --silent http://foobar.com/scripts/cronscript.php
To add Gzip handling:
curl --compressed http://foobar.com/scripts/cronscript.php
I usually use both, like:
curl --silent --compressed http://foobar.com/scripts/cronscript.php
I have a file in mysite.com/url1/url2/cronjob.php which has to be run every minute. I try every combination, but can't succeed. What should I run in command line? Thank you.
In case you'd set it up in a crontab, this works:
*/1 * * * * /usr/bin/wget -O /dev/null http://example.com/cron.php
Steps your shell
$ crontab -e
* * * * * php -f /path/to/cron.php
~
~
I got confused for the first time where to add all of these and finally found.
Type the following in the linux/ubuntu terminal
crontab -e
select an editor (sometime it asks for the editor) and this to run for every minute
* * * * * /usr/bin/php path/to/cron.php &> /dev/null
The PHP interpreter.
/[path-to-php]/php -f [your-php-script]
Are you looking for help to make an UNIX cronjob?
If so, have you tried to edit /etc/crontab, and add
\1 * * * * user command
where user is either root or your name. Im not exactly sure how to access and URL, but a dirty way could involve downloading the link as a file, e.g. "wget http://url.com/page.php"