12

I'm trying to setup a cron task in Plesk to run a short script every 5 minutes, I've just moved from a managed hosting account to a full access Plesk VPS, and I'm a little lost on a couple of things, this one in particular, when I go to Server > Scheduled Tasks I get a list of 'system users' as below, but I'm not sure under which user to make the cron task, any ideas?

  • adm
  • apache
  • bin
  • daemon
  • ftp
  • games
  • gopher
  • .. going all the way down to webalizer

The cron script path is below if that's relevant as to which user to choose -

/var/www/vhosts/mysite.com/httpdocs/scripts/index.php
Nikola
  • 14,888
  • 21
  • 101
  • 165
sam
  • 9,486
  • 36
  • 109
  • 160

3 Answers3

23

If you are going to create subscription-level task, than you can create cron/windows scheduler task in:

"Subscriptions" > your subscription > "Websites & domains" > click on "Show advanced operations" > "Scheduled Tasks" > there will be only one name of FTP user of your subscription.

Note: Pay attention to interface changes for Plesk 11.5 and Plesk 12+ - there is no need to open "Show advanced operations".

The latest Plesk 12.5 provide a lot of options to cover most of the task cases:

Plesk 12.5 Plesk schedule run PHP script

Other Plesk versions support only "Run a command" option:

Plesk 12.0

plesk-12.0-scheduled-tasks

Plesk 11.5

plesk-11.5-scheduled-tasks

If you need just answer, in "Server" -> "Scheduled Tasks" you can choose:

  • FTP user of your subscription mysite.com

  • your can choose root, but it's not recommended for security reasons.

For Plesk version below 12.5 to schedule execution of PHP script on Windows there is two ways:

  1. Direct call of php binary with your script as argument.

    Path to executable file: C:\Program Files (x86)\Parallels\Parallels Panel\Additional\PleskPHP55\php.exe

    Arguments: path to you script like C:\inetpub\vhosts\domain.tld\httpdocs\script.php

    Note: Pay attention to interpretation path, ...Additional\PleskPHP55\php.exe it path for PHP 5.5, you can change PleskPHP55 to PleskPHP5, PleskPHP53 or PleskPHP54 to use another PHP version.

  2. Call script via request to your site:

    Path to executable file: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    Arguments: -c "(new-object system.net.webclient).downloadstring('http://domain.test/script.aspx')"

kenorb
  • 155,785
  • 88
  • 678
  • 743
Oleg Neumyvakin
  • 9,706
  • 3
  • 58
  • 62
  • I'm Using Plesk With Windows Hosting and have hosted a PHP website Tried to schedule Task , i.e, A PHP script which should run every day. but what should be the Path to execute and Arguments i tried out several things like php.exe path and file path etc all resulted in an error like. it is not recognized as an internal or external command, operable program or batch file. – NaveenThally Jan 30 '15 at 12:59
  • 1
    You can find it here: http://download1.parallels.com/Plesk/PP11/11.5/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=64993.htm – Oleg Neumyvakin Jan 31 '15 at 06:22
  • I've add info from link above into answer. – Oleg Neumyvakin Jan 31 '15 at 06:31
  • I came across that it was real useful but for some reason i'm not able to run the script. it schedules as intended and i tried out to send a mail but it doesn't send but the triggering of schedule task is absolutely fine – NaveenThally Jan 31 '15 at 10:24
  • If you have RDP access to server you can open cmd console, combine full command(with interpreter path and path to your script) and check output. – Oleg Neumyvakin Jan 31 '15 at 13:57
  • I tried after getting the access to RDP when i executed i get some other values like paralle plesk 11.5 on windows and some thing irrelevant all i had done is just echoed hi in the php script but doesn't no from where the output is coming – NaveenThally Feb 11 '15 at 12:31
  • 1
    It means that you are using wrong php binary, use this one "C:\Program Files (x86)\Parallels\Parallels Panel\Additional\PleskPHP53\php.exe" – Oleg Neumyvakin Feb 11 '15 at 14:10
  • 1
    You are Genius, It was the problem of wrong php binary as you mentioned and altered as per your guidance and it works like a charm, I have been Facing one more problem in VPS http://stackoverflow.com/questions/28473693/payment-gateway-response-page-displays-empty-values-in-vps-hosting Any suggestion would be helpful – NaveenThally Feb 12 '15 at 09:28
4

https://www.motherhost.com/help/creating-or-removing-scheduled-tasks-in-plesk/

Creating a Scheduled Task in Plesk 10:

You can set up Scheduled Tasks in Plesk by doing the following:

Log into Plesk*
Click on the Websites & Domains tab.
Click on Show Advanced Operations (a small grey link in the middle of the page), if the advanced options are not already shown.
Click on Scheduled Tasks.
Select the appropriate system user.
Click on Schedule New Task.
Fill out the form as follows:
    Switched On:  Check the box to turn on the scheduled task.
    Description:  A short description to remind you what this scheduled task does.
    Scheduler Notification:  If you want an email every time this runs, select the appropriate option, otherwise select Do Not Send.  You may provide an email address where you want the notifications sent to.
    Path to executable file:  Specify the path to the file you wish to execute.  For Windows servers, it would be something like this:
    C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\php-cgi.exe
    Arguments: D:\Inetpub\vhosts\mydomain.tld\httpdocs\myscript.php
    For Linux servers with Plesk, ir would be something like this:
    /var/www/vhosts/domain.tld/httpdocs/myscript.php
    Replace domain.tld with your domain name, and myscript.php with the appropriate subfolder(s) (if any) and filename.
    Task Priority:  Select Low, Normal or High.
    Specify when to run your command by selecting the appropriate checkboxes in the Hours, Days of month, Months or Days of week fields.
    Click OK to schedule the task or click Run Now to schedule the task and immediately run it.
You will be taken back to the Scheduled Tasks screen and you should see your new scheduled task listed at the bottom.

Removing a Scheduled Task in Plesk 10

Logging into Plesk*
Click on the Websites & Domains tab.
Click on Show Advanced Operations (a small grey link in the middle of the page), if the advanced options are not already shown.
Click on Scheduled Tasks.
Select the appropriate system user.
Check the box next to the Scheduled Task you want to remove.
Click on the Remove button.
It will load a new page and ask if you really want to deleted it.  Check the Confirm Removal box and click on the OK button.
You will be taken back to the Scheduled Tasks screen and it should say: "Information: Scheduled tasks were removed."
Ramnath
  • 193
  • 7
  • may be this path D:\Inetpub\vhosts\mydomain.tld\httpdocs\myscript.php could change make sure of it. it was totally different for me. – Lokesh Dec 20 '13 at 08:13
3

Use this command:

php -q httpdocs/scripts/index.php
kenorb
  • 155,785
  • 88
  • 678
  • 743
Arjan
  • 31
  • 3