Maxy.fr

Scheduling a Cron task from a Synology NAS

If you are using a Synology NAS as a local web server and want to automatically execute PHP scripts at regular intervals, here's the procedure to follow:

- First, log in to the web interface of your NAS and open the control panel.

- Click on "Task Scheduler" and then "Create" > "User-defined script":

- Next, you will need to choose a name for this new task, the user to be used for execution (default is root), and the command to execute.

Here, if you want to run a PHP script, you will use a command like this:

/usr/bin/php -f /volume1/web/test/RecupDispo/index.php

This command will simply execute the PHP page index.php.

If you want logs to be recorded each time, you will need to add a line to the command, like this:

/usr/bin/php -f /volume1/web/test/RecupDispo/index.php >> /volume1/web/test/RecupDispo/log.txt

- The last step is to configure the time interval between each script execution. Click on the "Schedule" tab at the top of the page.

The form is quite intuitive, so you can adjust the interval as you like.

(This example will allow daily execution every 30 minutes throughout the day)

 

(This second example will allow execution every hour from 12 PM to 6 PM only on weekends)

Catégories : Synology

Par Guillaume le 20/06/2016 à 00:52

Partager l'article :

Articles similaires