Search code examples
curlsynology

Copy file on Synology using the Task Scheduler


I'm trying to copy a small text file from/to locations which are located under different subfolders of the "web" main folder.

The source is 'web/Domoos/php_scripts/auto/file/myfox_token.txt' and the destination is 'web/Demo/0h/php_scripts/auto/file/myfox_token.txt'.

Based on a previous post on stackoverflow (Copying local files with curl), I have tried to implement this logic in my Synology DS415+, which runs under DSM version 6.2.3 (Update 2) by adding a new task and entering the following in the command line:

curl -o file://"web/Domoos/php_scripts/auto/file/myfox_token.txt" > "web/Demo/0h/php_scripts/auto/file/myfox_token.txt"

Unfortunately, I was not successful. Then I tried to enter the same using the IP address of my NAS (192.168.X.X) :

curl -o "192.168.X.X/web/Domoos/php_scripts/auto/file/myfox_token.txt" > "192.168.X.X/web/Demo/0h/php_scripts/auto/file/myfox_token.txt"

This was not successful, either.

Could it be that the "curl" function is not supported on Synology as I would like it to be ?

Many thanks for reading my post and best wishes.


Solution

  • I respond to myself, hoping that this post could be helpful to someone else.

    I created a bash script and went in the 3rd tab of the task scheduler editor "task settings".

    I entered the following

    #!/bin/bash
    # For demo 0h folder
    sleep 15s
    cp /volume1/web/Domoos/php_scripts/auto/file/myfox_token_extracted.txt /volume1/web/Demo/0h/php_scripts/auto/file/myfox_token_extracted.txt
    

    enter image description here enter image description here enter image description here

    Please keep in mind that :

    1. #!/bin/bash is a so-called 'Shebang' which will instruct your Synology OS to parse the rest of the command line(s) as an interpreter directive.
    2. The second line is just a comment example and starts with the hash character (#).

    Best wishes and stay healthy