Task Scheduler - Script not running

Questions pertaining to Power settings, Auto Block, Permissions, User Quotas and Email alerts may be posted here.
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:

https://account.synology.com/support/su ... p?lang=enu



2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
Fluwk
I'm New!
I'm New!
Posts: 1
Joined: Wed Jun 13, 2018 10:23 am

Task Scheduler - Script not running

Unread post by Fluwk » Wed Jun 13, 2018 10:34 am

Hello

I was working on a script to move all subfolders and files from a specific folder to a 'archive' folder.
When executing the commands via SSH, all is fine but when I upload the script to my NAS, give it chmod 775 and execute it on the task scheduler nothing happens.
I've added a line for debugging in the task scheduler, the error code is pasted below.

This is what the script looks like:

Code: Select all

#!/bin/sh
cd "/volume1/<folder>/"
mkdir "$(date +"%d-%m-%Y")"
cd /volume1/<folder>/
mv * "/volume1/<archive folder>/$(date +"%d-%m-%Y")"
This is what the 'User defined script' looks like in the task mananger:

Code: Select all

/bin/bash /volume1/<folder>/MoveFilesFromGuestToArchive.bash >>/tmp/task_debug.out 2>&1 
The Error code in the debug looks like this

Code: Select all

/volume1/<script folder>/MoveFilesFromGuestToArchive.bash: line 1: <feff>#!/bin/sh^M: No such file or directory
/volume1/<script folder>/MoveFilesFromGuestToArchive.bash: line 2: cd: /volume1/<archive folder>/^M: No such file or directory
mkdir: cannot create directory '13-06-2018\r': File exists
/volume1/<script folder>/MoveFilesFromGuestToArchive.bash: line 4: cd: /volume1/<folder>/^M: No such file or directory
mv: target '/volume1/<archive folder>/13-06-2018' is not a directory
I did notice the '<feff>' and '^M' code but already tried setting this to UNIX format with Vim.

If anyone can help me out with the problem, i'd be gratefull! :D

Thanks

User avatar
Rusty1281
Proficient
Proficient
Posts: 2782
Joined: Fri Jun 03, 2011 10:51 pm

Re: Task Scheduler - Script not running

Unread post by Rusty1281 » Wed Jun 13, 2018 12:15 pm

Guessing you are running that script as root account or?
Synology DS918+ (4x4TB WD RED - RAID 5 with 2x250GB 960EVO NVMe) | Synology DS412+ (4x3TB WD RED - RAID 5) | RT1900AC

pwhooftman
Seasoned
Seasoned
Posts: 590
Joined: Tue Feb 12, 2013 7:53 pm

Re: Task Scheduler - Script not running

Unread post by pwhooftman » Wed Jun 13, 2018 7:29 pm

open the script in an editor like vi and remove all those ^M like codes.
DS412+ with 3x2Tb WD Red

Post Reply

Return to “System Management”