Setting up cron task in Plesk 11

sam picture sam · May 22, 2013 · Viewed 38.2k times · Source

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

Answer

Oleg Neumyvakin picture Oleg Neumyvakin · May 23, 2013

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')"