开发者

PHP script in /etc/cron.weekly

I ha开发者_开发百科ve a php script in my website folder that needs to be executed weekly.

I am on debian 6 (root).

How can I run this php script (in cli) weekly wihtout using crontab ?

I mean which kind of file should I copy in /etc/cron.weekly to run my php file?


Just use an executable PHP script with a "shebang" line:

#!/usr/bin/php
<?php
// Your PHP code goes here
echo "Hello World!";
?>

Make it executable:

$ chmod +x myscript.php

Test it:

$ ./myscript.php
Hello World!

The "shebang" (#!) tells the shell that this script is to be executed with PHP, found in /usr/bin/php.

Alternatively, you could write a small shell script that invokes the PHP interpreter with your PHP script:

#!/bin/bash
/usr/bin/php -f /path/to/script.php
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜