Categories

定時任務

甚麼是定時任務?

定時任務是於伺服器中的一項功能,能允許用戶在特定的時間自動執行腳本。

假設,使用者可以設置一個特定的PHP腳本,在午夜每天自動執行一次。

於cPenal中設置

  1. 登入cPanel
  2. 前往 Advanced 部份
  3. 點擊 Cron Jobs 圖示
  4. 填寫特定間去執行指定項目
  5. 最後填寫執行的腳本到 Command

You should make sure to enter the proper command and the full path to the file.

For example: /user/bin/php/home/user/public_html/cron.php
If you are not sure the command path, you could ask your hosting angency.

Extension Cron Jobs

Extension Cron Jobs

Setup in Plesk Panel

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

  1. Log on to your Plesk Panel Interface.
  2. Go to "Subscriptions" section click "Your Subscription".
  3. Select "Websites & domains"
  4. Click on "Show advanced operations"
  5. Select "Scheduled Tasks"
  6. There will be only one name of FTP user of your subscription

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:

The latest Plesk 12.5 provide a lot of options to cover most of the task cases
Extension Cron Jobs

Other Plesk versions support only "Run a command" option:
Plesk 12.0 Extension Cron Jobs


Plesk 11.5 Extension Cron Jobs

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