Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I am trying to set up some application background processes to start on boot using systemd. It always gives me 127 exit code and I am not sure why. I thought that ExecStart command is being executed in a wrong directory. So I added ExecStartPre to output the current directory but it was not executed as well.

Here is my service file:

[Unit]
Description=Background processes

[Service]
Type=simple
User=epic
Environment=RAILS_ENV=production
WorkingDirectory=/home/epic/application
ExecStartPre=/bin/pwd > /home/epic/test.sys
ExecStart=/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake jobs:work

And the messages log shows when I execute systemctl start epic.service:

Apr 24 05:13:01 application systemd[1]: epic.service: main process exited, code=exited, status=127
Apr 24 05:13:01 application systemd[1]: Unit epic.service entered failed state.

How can I know what is going wrong! I tried to execute the command in shell and it works (if it was in the right directory). The server is running on Fedora 15.

share|improve this question

1 Answer 1

systemd does not support arbitrary shell commands with its Exec* statements, thus the redirection you're trying will not work. You could write a quick script and call that:

/home/epic/pwd.sh:

#!/bin/sh
/bin/pwd > /home/epic/test.sys

ExecStartPre=/home/epic/pwd.sh

Also you may want to read up on rvm wrappers to see if that would be better than calling rake directly from the rvm installation path, http://deepakprasanna.blogspot.com/2011/06/rvm-wrappers.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.