2

I got always an error message that my upstart script doesn't start.

start: Job failed to start

My script is:

description "Tagger Version 2"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 2 5

pre-start script  

mkdir -p /run/lemmatization/Lemmatizer  
chown nobody /run/lemmatization -R  

end script

setgid nogroup
setuid  nobody

exec some_shell_skript.sh

The problem must be in the pre-start section, since everythink works fine if I comment it out.

5
  • Check the logfile /var/log/upstart/<your_job_name.log> for more infos/error messages and post them please in your question.
    – chaos
    Commented May 19, 2015 at 10:16
  • ah, thanks a lot I got the following messages: mkdir: cannot create directory '/run/lemmatization': Permission denied but I thought the script runs with root permission, doesn't it?
    – Ulli
    Commented May 19, 2015 at 10:53
  • 1
    yes, but in your upstart job I see setuid and setgid. They are there to run a job as another user/group. And nobody has no permissions to create the directory
    – chaos
    Commented May 19, 2015 at 11:08
  • Thanks a lot for the very helpful comments. Ok, i see the problem. I want to start the process with user nobody but for the creation of the directory I need root permissions. Is there some way to do this?
    – Ulli
    Commented May 19, 2015 at 11:13
  • See my answer, I described the upstart job
    – chaos
    Commented May 19, 2015 at 11:22

1 Answer 1

2

Since you want to execute the pre-start stanza as root and the start stanza as nobody you have to use sudo. Try it with that upstart job:

description "Tagger Version 2"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 2 5

pre-start script  

mkdir -p /run/lemmatization/Lemmatizer  
chown nobody /run/lemmatization -R  

end script

exec sudo -u nobody -g nogroup some_shell_skript.sh

As you see I removed the setuid/setgid part completely and used sudo instead to execute your script as another user.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .