• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

crontab

R

robinthecam

Guest
Hi there,

I´m a newbie on setting up cron jobs... My Problem is, i want to execute a .php script on a specified time! can someone tell me what is the syntax for my command!

Thanks in advance
r
 
1) find where your php interpreter resides

$ which php
/usr/local/bin/php

2) Add the following line to begin of you php script:

#!/usr/local/bin/php -q

3) make you php script executable

$chmod 755 /path/to/your/script.php

4) Make sure you script works properly by trying to start it from the command line

$ /path/to/your/script.php

<script output here>

5) add command line to your crontab

$ crontab -e

For example, to start script every day at 5:00:

0 5 * * * /path/to/your/script.php
 
duh ?

Hey guys,

Isn't this supposed to be the Windoze thread???

Or am i missing something?
 
Thanks defencer,

Can you tell me what this does:

Originally posted by defencer
#!/usr/local/bin/php -q

Also...

when i access this file from http it works fine, but from shell i get these errors.

/home/httpd/vhosts/site/httpdocs/ts/page.php: ?: No such file or directory
/home/httpd/vhosts/site/httpdocs/ts/page.php: line 3: syntax error near unexpected token `set_time_limit(0)'
/home/httpd/vhosts/site/httpdocs/ts/page.php: line 3: `set_time_limit(0);'

Thanks!
 
ahh i think it was because i added the code inside the <?


#!/usr/local/bin/php -q
<?
echo "hello";
?>

works!

i am getting this error in my actual file which works great through http, but not thorough shell.

Fatal error: Call to undefined function: iconv() in /home/httpd/vhosts/site/httpdocs/tb/file.php on line 237

$xml = iconv("ISO-8859-1", "UTF-8",$xml);
 
Are you running windows or linux? It makes a difference. This is a Windows forum and it looks like you are talking about Linux
 
<Gack> yeah the previous post seemed relevant. maybe a moderator can cut this thread to plesk 6.0?
 
Back
Top