I try to create a cron on a server (I should have right on it).
This is my script cron.php
:
<?php
echo "CRON OK \n";
?>
I connect with SSH and create the following cron with crontab -e
:
* * * * * php /home/myname/www/cron.php
But I don't know how to save it.. Anyway I save the crontab at the default location /tmp/crontab.XAblsdZ/crontab
, the server tell me "crontab: installing new crontab" and when I execute crontab -l
I can see * * * * * php /home/myname/www/cron.php
.
I also try my script : php /home/myname/www/cron.php
The server display "CRON OK" so I guess it works.
But without this command I can't see any "CRON OK" displayed... Am I missing something ? How to enable this cron and execute my script every minute?
either add #!/usr/bin/php as suggested or you could add it to your crontab, make sure the /usr/bin/php is actually the right path to your PHP.
* * * * * /usr/bin/php /home/myname/www/cron.php
The cron line looks good to execute every minute though.
尝试将其添加到cron.php
的开头:
#!/usr/bin/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.