• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Schedule a PHP script

E

EddieA

Guest
Hello everyone,

Centos Linux 2.6.18
Panel version 10.2.0


I would like to know what command should I use to run a PHP script uploaded via FTP everyday at 2 am.

I do now know what command I should use.
The file is located in: /var/www/vhosts/DOMAIN/###/example.php

In all other variables of the form "Schedule a Task" i have:

Minute: 0
Hour: 2
Day of the month: *
Day of the week: *
Month: *


Can you help me with the command?
 
Last edited by a moderator:
Hi EddieA,

I've had that problem recently too - you'll have to tell the command line the full path to PHP on your server. On CentOS it's

/usr/bin/php

so your full command under Scheduled Tasks should look like this:

/usr/bin/php /var/www/vhosts/DOMAIN/###/example.php

Notice there's a space between the actual command and the path to PHP.

Good luck ;-)
 
Thanks for your answer

I would like to know what the command is?

If I open the file on a browser it works perfectly.... I just have to put the url...

I read that it should be something like this:

#!/var/www/vhosts/DOMAIN/###/example.php

But probably is something else like:

open /var/www/vhosts/DOMAIN/###/example.php


Do you know the command???


Greetings,
Eddie

Hi EddieA,

I've had that problem recently too - you'll have to tell the command line the full path to PHP on your server. On CentOS it's

/usr/bin/php

so your full command under Scheduled Tasks should look like this:

/usr/bin/php /var/www/vhosts/DOMAIN/###/example.php

Notice there's a space between the actual command and the path to PHP.

Good luck ;-)
 
That IS the command.

OK so let's assume in your web browser the following file is your file:

http://www.yourdomain.com/test.php

Then you can call it as a scheduled task like this:

/usr/bin/php /var/www/vhosts/yourdomain.com/httpdocs/test.php

Obviously replace test.php with your actual file, and yourdomain.com with your actual domain.
 
Not working

Thank you for your advice but it is not working :(

I think this should be easy ...
 
PHP scripts are usually written so that they execute something that gets displayed in a browser. If you're using PHP as a scripting language for command line execution the results may well be very different. Who write the script, and what does it do?

Also, the first line of the PHP file should start with #! /usr/bin/php I believe (similar to a shell script).
 
Back
Top