Dear PHP guru(s)
I have a problem of running php in linux. I wrote a php program and currently running in the webbrowser. I would like to automate this program using crontab. I configure crontab using root user.
0 23 * * * /var/www/html/modules/autoemail_events.php >/dev/null
Although I can run successfully in webbrowser, it can't run in unix. There a lot of problem occur while running.
So I create another php program, which only has two lines.
<?
$myname="crontab_test";
echo $myname;
?>
error occurs
command not found
./wtnyan.php: line 1: =crontab_test: command not found
I dont know why. I run ./wtnyan.php in the linux shell also the same problem.
Please kindly help me. Thanks
Cannot run php in linux
Moderator: General Moderators
Shell Script php
Hi all
I managed to find out how to make shell script PHP.
In PHP file
Just add #!/usr/local/bin/php -q
In crontab
0 23 * * * php /var/www/html/modules/satanet/autoemail_events.php >/dev/null
Below is the information site.
http://www.phpbuilder.com/columns/darrell20000319.php3
Thanks all.
I managed to find out how to make shell script PHP.
In PHP file
Just add #!/usr/local/bin/php -q
In crontab
0 23 * * * php /var/www/html/modules/satanet/autoemail_events.php >/dev/null
Below is the information site.
http://www.phpbuilder.com/columns/darrell20000319.php3
Thanks all.
Re: Cannot run php in linux
wtnyan wrote:Dear PHP guru(s)
I have a problem of running php in linux. I wrote a php program and currently running in the webbrowser. I would like to automate this program using crontab. I configure crontab using root user.
0 23 * * * /var/www/html/modules/autoemail_events.php >/dev/null
Although I can run successfully in webbrowser, it can't run in unix. There a lot of problem occur while running.
So I create another php program, which only has two lines.
<?
$myname="crontab_test";
echo $myname;
?>
error occurs
command not found
./wtnyan.php: line 1: =crontab_test: command not found
I dont know why. I run ./wtnyan.php in the linux shell also the same problem.
Please kindly help me. Thanks
You could also directly run the script using
0 23 * * * /usr/bin/php /var/www/html/modules/autoemail_events.php >/dev/null
without specifying within the script which interpreter to run it.
Re: Cannot run php in linux
Search the web for 'she-bang' lines. If you want to launch a program like this, the first line has to be the path to the program/interpreter you want to use for the file...wtnyan wrote: Although I can run successfully in webbrowser, it can't run in unix. There a lot of problem occur while running.
So I create another php program, which only has two lines.
<?
$myname="crontab_test";
echo $myname;
?>
command not found
./wtnyan.php: line 1: =crontab_test: command not found
Eg:
Code: Select all
#!/usr/bin/php
<?php
echo 'Hello World';
?>If you don't know the actual path to your php interpreter, you can find it with the command 'which php'.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia