Cronjob every minute - 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"

Related

Cronjob for localhost xampp on MacOS

I setting on the host this cronjob and it work but, I need local and dont know how it work
my code is:
1 step
open terminal and type
crontab -e
2 step
write this code
* * * * * wget --spider -O - /Applications/XAMPP/xampfiles/htdocs/mysite.local/index.php/cron/comment >/dev/null 2>&1
3 step
save and close file.
but not work... where is problem?
You need to use the absolute path of the script.
* * * * * /usr/bin/wget --spider -O - http://insta.local/cron/comment >/dev/null 2>&1

Why my crontab not working using wget command?

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.

Cron job with CodeIgniter using wget

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...

cronjob is not working Linux

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

cron tab not working

I have this code bellow to run in command line but is not working. I tried in command line to run without the cron tab and it works. Anyone knows how to fix it ? Thanks in advance.
*/5 * * * * /usr/bin/php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /dev/null 2>&1
Crontab line is ok:
*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php
I think the problem with script.
try to run it manualy:
php /var/www/html/ulchemdb/File_upload/uploads/crontab.php
or if You don't have opportunity to get to console do following:
enable error reporting
add line to then end of crontab.php:
echo "\nCOMPLETED SUCCESSFULY\n"
add this crontab line:
*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php >> /var/www/html/ulchemdb/File_upload/uploads/crontab.log
Also You can share with us Your code, we'll try to help You somehow.
Where is your php is? It can be clarified with "which php" or "whereis php" commands. Use this path as your php executable path.
Try to execute this command manually. Is it works? If no => problem not in crontab.
If yes => remove output redirecting to dev/null for a time (remove part " > /dev/null 2>&1"), use redirecting to log file, for instance:
*/5 * * * * PATH-TO-PHP/php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /var/log/php.log 2>&1
Investigate a log after some time. Is there something? If no => make sure you script have some output.
try
*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /dev/null 2>&1

Categories