A simple trick to adjust the scheduled run time of a script is to use the unix
Example: I have a script that copies files from one remote folder to another local one. The remote server creates the new files on each quarter hour. The files take just over a minute to complete.
I therefore want to be over a minute past each quarter hour before starting the copy to the NAS. But DSM's task scheduler only gives me options to run tasks every 1, 5, 15 mins, etc. So instead of running the task every minute and working out if the current minute is one I want (using complicated expansion of
I prefer to copy the files to the NAS than have the remote folders mounted in /web and directly accessed from the Internet (even if the remote shares are read-only).
sleep
command as the top of the script.Example: I have a script that copies files from one remote folder to another local one. The remote server creates the new files on each quarter hour. The files take just over a minute to complete.
I therefore want to be over a minute past each quarter hour before starting the copy to the NAS. But DSM's task scheduler only gives me options to run tasks every 1, 5, 15 mins, etc. So instead of running the task every minute and working out if the current minute is one I want (using complicated expansion of
if ... date +%m = <min I want> ... then ...
) I select the task to run every 15 minutes (00/15/30/45) and within the script it starts:
Bash:
#!/bin/bash
#run every 1/4 hour but wait for files to be updated (1.5 mins delay)
sleep 90s
<rest of script>
I prefer to copy the files to the NAS than have the remote folders mounted in /web and directly accessed from the Internet (even if the remote shares are read-only).