I've created a cron job in AWS EC2 but it is not working.
I followed below steps to create cron tab:
crontab -e
* * * * * php/var/www/html/welcome.php
(To run every min.) :wq
Cron tab is created but not running.
Please can you any one help me if is there any PHP script means please provide me. Do I need to give spaces between every star?
First of all, you need to put an space between php
and /var
:
From
* * * * * php/var/www/html/welcome.php
to
* * * * * php /var/www/html/welcome.php
^
Then, you'd better use /bin/php
instead of just php
. To determine where the php
executable is located, type which php
in your console, it will give you the file path. So it will become something like this:
* * * * * /bin/php /var/www/html/welcome.php
^^^^^^^^
More things:
crontab -l
. Your new crontab line should be there. ls -l /var/www/html/welcome.php
. /bin/php var/www/html/welcome.php
to see if it is a script or crontab problem. chmod 755 /var/www/html/welcome.php
Keep us updated so we can find what can be causing the error.
Running cron on EC2 is not any different from running on any *nix server - as far as I know. I would check of the system messages for any errors. You can also redirect stderr/stdout to a file as in
* * * * * <your script> >> /var/tmp/out.log 2>&1
and check for any issues for starters.
可能为时已晚,但如果您打算每分钟运行一次该命令应该是该命令
* * * * * php /var/www/html/welcome.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.