I have created following command line to run cron job after every 2minutes
2 * * * * php -f /home/u260451427/public_html/cron/cron_sms_sending_queue.php
my sever configuration look something like that
but its not working.
2 * * * * <command> will run every 2nd minute past every hour.
From 'man 5 cron':
Step values can be used in conjunction with ranges...
Steps are also permitted after an asterisk, so if you
want to say ``every two hours'', just use */2
Therefore your crontab entry should be
*/2 * * * * <command>
Related
I have some .php files, some are in root foler and some are inside a directory say "cron_jobs" and I have added cron jobs for these files on server like as below :
*/2 * * * * php /home/public_html/mysite/demo_root.php
*/2 * * * * php /home/public_html/mysite/cron_jobs/demo.php
There are two cron job, where first cron job executing properly but second cron job not executing from server.
And "cron_jobs" directory has permission 755.
Why cron job not executing which are not in root folder?
Is there in any setting for this or Am I doing something wrong to add cron job?
I changed cron job from :
*/2 * * * * php /home/public_html/mysite/cron_jobs/demo.php
To
*/2 * * * * cd /home/public_html/mysite/cron_jobs/ php demo.php
and It is working for me.
I am using Codeigniter to develop my site and it's running on Apache installed in Ubuntu.
I want to run a cron. I am using Codeigniter routing and I have also removed index.php from route.
My controller is home function is winner.
I tried following two ways but no one seems to be working.
#49 5 * * * /usr/local/bin/php /var/www/project/web/index.php home winner
13 6 * * * /usr/bin/curl http://www.project.com/home/winner
Check that lynx installed in your system (e.g. command "whereis lynx")
Then edit crontab's config (command "crontab -e")
Put this command with MAILTO option in your crontab's config (in the same order, on the first line "mailto" option, on the next line other options):
MAILTO=your#email.com
*/5 * * * * /usr/bin/lynx -source http://www.project.com/home/winner
With those settings cron will be start every 5 minutes. And if will be some errors there, cron will send it email on address that you set in MAILTO option.
[Tested on Debian 4.7.2]
Try this in your cPanel cron job setup.
This is to run every 5 minutes:
*/5 * * * * curl http://yoursite.com/class/function
https://www.drupal.org/docs/7/setting-up-cron-for-drupal/configuring-cron-jobs-using-the-cron-command
I am trying to run PHP file on path /var/www/html/rss_feed/mirror.php through cron tabs. For this I performed the below steps.
sudo crontab -e
Then I edited the file by inserting the following code
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# avt 5 a.m every week with:
# 0 5 * * 1 tar -zcf /ar/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
*/2 * * * * /usr/bin/php /var/www/html/rss_feed/nbt_times.php
#
# m h dom mon dow command
As you can see below is the line of code inserted to schedule cron tab after every 2 minutes to run a php file.
*/2 * * * * /usr/bin/php /var/www/html/rss_feed/nbt_times.php
I even tried following
2 * * * * lynx -dump http://192.168.0.232/rss_feed/mirror.php > /dev/null 2>&1
and even this
2 * * * * /your/path/to/php /var/www/html/rss_feed/nbt_times.php
and many more formats from different articles.
The php script is not running. Do I need to put the code somewhere else? Or I am on the wrong way. Can you please help me find out what is the issue.
It should work but need to get some clarifications here, file name seems to be different one time its mirror.php and another time its nbt_times.php
which php file has to run on the specific time that has to be specified. As you specified you're running /var/www/html/rss_feed/mirror.php then, then specify mirrror.php on your first command .
The 2nd and third command will run the job for 2nd minute of every hour. like (4:02,5:02,6:02, etc)
Try this crontab
*/2 * * * * /usr/bin/php /var/www/html/rss_feed/mirror.php
This will run for every 2 mins hope this works.
Try with php5-cli:
*/2 * * * * /usr/bin/php5-cli -f /var/www/html/rss_feed/nbt_times.php
Also add write to logs and see them after minute:
* * * * * /usr/bin/php /var/www/html/rss_feed/nbt_times.php >>log.log 2>>log.err
Check permissions of your php-file. Make 0777 for checking. Try create the simplest php file with one row and run it via cron.
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 to execute a url for every 2 min in php so i followed the steps
1) crontab -e
2)select nano editer
3)insert the line
* * * * * /usr/bin/GET http://www.gmail.com/sendMail
After saving the file I got the response
no crontab for root - using an empty one
crontab: installing new crontab
Is there any wrong with the command.
Can any one help me out.
you can use curl for hitting URL
follow following steps :
crontab -e
add following line to the file
*/2 * * * * /usr/bin/curl www.google.com
to know more about curl you can do
man curl