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...
Related
I setup several cron jobs to make things work. laravel scheduler works perfectly but my other cronjobs not working at all.
*/2 * * * * /usr/bin/php /var/www/cronjobs/index.php
when I run on the console /usr/bin/php /var/www/cronjobs/index.php it works properly. I checked executable php path with which php and gives me /usr/bin/php nothing wrong with path afaik. I tried to run php script as apache user www-data I opened crontab with crontab -u www-data -e and paste command there.. it didn't work too.
I also tried send dummy notify with crontab and it also didn't work either
dummy example
* * * * * /usr/bin/notify-send 'test'
both of them doesn't work. What am I missing here ?
The second command will not send notification as cron have no idea of your desktop environment.
The first command probably use some environment variables. So instead of run in command line you can try to create a script:
#!/bin/bash
source /path/to/user/home/.bashrc #you can try also .bash_profile
/usr/bin/php /var/www/cronjobs/index.php
and your cron to be like:
*/2 * * * * /path/to/script.sh
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.
I worked on magento and I want to run cron job on the server.
If I run domainname/magentofolder/cron.php in the address bar it works.
But when I try to set up cron job on cpanel it will not working.
If executing the php cron file doesn't work you can also try so set up the cron to use the cron.sh file like this:
*/5 * * * * /bin/sh /absolute/path/to/magento/cron.sh
Try this
*/5 * * * * wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php > /dev/null
more information is on xtento
I've been at this for hours and have tried everything with no luck.
I am basically trying to run this http://docs.phpservermonitor.org/en/latest/install.html#setting-up-a-cronjob
I'm using MAMP and my localhost is a custom folder under User/username/localhost/servercheck
What I've tried so far is.
crontab -e
added */1 * * * * root /usr/bin/php /Users/clientsupport1/localhost/servercheck/cron/status.cron.php
And when I type crontab -l to see if its loaded I see the following.
*/1 * * * * root /usr/bin/php /Users/clientsupport1/localhost/servercheck/cron/status.cron.php
But the script does not run. I even tried a simple script that writes to a file. Still nothing. For some reason the cron job doesn't execute. Any ideas?
You need to call MAMP’s PHP executable, which will depend on on the version of PHP you’re running. For 7.2.1, the following below would be the proper path
*/1 * * * * /Applications/MAMP/bin/php/php7.2.1/bin/php /Users/clientsupport1/localhost/servercheck/cron/status.cron.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"