Scheduling data download

The program SWEMED_download_prompt.py can also be used to schedule data download in an automatic way. You can find here instructions on how to schedule tasks in Linux and Windows environments.

Scheduling tasks in Linux

Cron is a job-scheduler available in Unix-like operating systems that can be used to download data from our server in an automatic way. Typing "crontab -e" in the command line opens a text editor for adding a new task to the list to be run by cron.

For instance, the instruction for downloading the last two calibrated files available is:

python SWEMED_download_prompt.py L cal 2

To schedule this task to be performed every 10th minute, one must open the cron task editor and add to the following instruction:

*/10 * * * * python SWEMED_download_prompt.py L cal 2

More examples can be obtained here.

Scheduling tasks in Windows

Batch files (files with .bat extension) are scripts containing a set of instructions to be executed by Microsoft Windows command line interpreter. Taking into accout the previous example, the batch file should be similar to this:

"C:\Location\Python\interpreter\python.exe" "C:\Location\of\Program\SWEMED_download_prompt.py" L cal 2

It is advisable to use the Python interpreter's full path (which in the case of the Anaconda distribution can be found by typing "where python" in Anaconda's prompt) and that of the "SWEMED_download_prompt.py" program.

The execution of batch files can be scheduled by the OS's task scheduler (press the Windows key and type "Task Scheduler"). At the "Task Scheduler" click on the "Create Task" option from the "Actions" tab. Afterwards, define the "Trigger" as "Daily" and select the option "Repeat task every" indicating the desired time interval. In the "Action" section select "start a program", choosing the desired batch file. An illustrative batch file is provided here.