Schedule Trigger Task nok working for non root user

Any questions about the Command Line Interface can be placed 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.
kino101
I'm New!
I'm New!
Posts: 2
Joined: Tue May 15, 2018 11:07 pm

Schedule Trigger Task nok working for non root user

Unread post by kino101 » Tue May 15, 2018 11:55 pm

Hi,

I'm desperately trying to build a very basic scheduled triggered task under DSM 6.1, unfortunately it works only if run as root user.

More precisely, I've created a user-defined script triggered task setup with boot-up event, mail notification and the following very simple script:

Code: Select all

#!/bin/sh
echo "Hello"
If I run as root everything works great, and I receive a success email with the following content
Task: Test Task
Start time: Wed, 16 May 2018 00:44:00 GMT
Stop time: Wed, 16 May 2018 00:44:01 GMT
Current status: 0 (Normal)
Standard output/error:
Hello

but if I change to a different user (even with some users of administrators group) I receive a failure email with the following content:
Task: Test Task
Start time: Wed, 16 May 2018 00:48:29 GMT
Stop time: Wed, 16 May 2018 00:48:30 GMT
Current status: 1 (Interrupted)
Standard output/error:
Any ideas?

nixjps
Apprentice
Apprentice
Posts: 95
Joined: Fri Jun 09, 2017 1:39 pm

Re: Schedule Trigger Task nok working for non root user

Unread post by nixjps » Wed May 16, 2018 3:26 pm

Hi,

Right, when running a triggered task as non-root user, you might get this error unless you changed task scheduler default setup.

In fact what happens is that the scheduler saves the script in /tmp and runs it with redirecting stdout and stderr to.... a temporary file located in /volumeX... X being the last available volume....
As it runs the script as non-root user it fails because user has no write access to /volumeX.... (by default /volume, permission are 0755).

A work around is to enable output recording in "task scheduler/settings"....

Rgds,
DS916+ (8G) - DSM 6.1.3-15152u4 - ST8000VN0022-2EL112 x 3 - 1 SHR Disk Group - 2 volumes - Home Usage
DS216Play - DSM 6.1.3-15152u4 - ST4000DM000-1F2168 x 2 - Basic Disks - 2 Volumes - Off site backup of DS916+ and local browsing of Photos, Musics and Videos
DS916 and DS216Play MAN link (1Gb FFTH same ISP).
DS916 S2S -> DS216Play, HyperBackup of DS916 config & critical data to DS216Play. HyperBackup of DS216Play configuration and local data to DS916

kino101
I'm New!
I'm New!
Posts: 2
Joined: Tue May 15, 2018 11:07 pm

Re: Schedule Trigger Task nok working for non root user

Unread post by kino101 » Wed May 16, 2018 10:14 pm

Thank you very much Nixjps for your answer and the details :)

I didn't know about the "task scheduler/settings", I tried your workaround and it works perfectly.

More over, your solution redirects the stdout and the sdterr to a file, before posting my question I was wondering if it was possible...

So once again thanks! :D :D :D

Post Reply

Return to “Command Line Interface”