I have a upstart configuration file as shown below which works fine in Ubuntu 14:

#/etc/init/data_server.conf
#sudo start data_server
#sudo stop data_server
#sudo status data_server

start on runlevel [2345]
stop on runlevel [016]

chdir /opt/hold/data_server
respawn

post-start script
    echo "data server started at `date +"%F %T"` on `hostname -f`" | mailx -r "abc@host.com" -s "data server Started" "pqr@host.com"
end script

post-stop script
  sleep 30
end script

limit core unlimited unlimited
limit nofile 100000 100000
setuid goldy
exec ./proc_server --init_file=../config/tree.init --port=8080 --dir=/data/hold/ --max_sec=2400 --max_mb=100 --active=5

Now we are moving to Ubuntu 16 so we can't use upstart and looks like we need to use systemd here. I have to make sure whenever system is rebooted or app is killed it should start my systemd script automatically which in turn start my data server. So I came up with below systemd script: Let me know if this is the right way as I am doing it for the first time?

[Unit]
Description=test server
After=network.target
StartLimitIntervalSec=0

[Service]
User=goldy
Group=goldy
Type=simple
WorkingDirectory=/opt/hold/data_server
ExecStart=/opt/hold/data_server/proc_server --init_file=../config/tree.init --port=8080 --dir=/data/hold/ --max_sec=2400 --max_mb=100 --active=5
Restart=always
RestartSec=3
LimitNOFILE=100000
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

Whenever I run above script, it gives me this error, I am not sure whats wrong?

[/lib/systemd/system/queue_server_two.service:3] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit'

You are likely comparing systemd docs you've read online for a different version instead using the docs on your system that match your version.

Check man systemd.unit on your own system. You may find that on your version, the directive is named

StartLimitInterval= and should be used [Service], not [Unit].

I found the answer by searching for systemd StartLimitIntervalSec.

  • make sense thanks.. also is there any way I can add emailing thing in my systemd script just like I have in upstart? – user1950349 Mar 27 at 20:50
  • @user1950349 ExecStartPost= – Michael Hampton Mar 27 at 21:34
  • systemd syntax doesn't support pipes, so you'll need something like ExecStartPost=/bin/bash -c ''. Then you can put your command back in there as a quoted bash string. As seen in man systemd.unit, you can use %H for the host name, avoiding the call to hostname -f. – Mark Stosberg Mar 28 at 11:51
  • got it.. so that means this below line should work? – user1950349 Mar 28 at 19:36
  • 1
    @jamshid man systemd.directives will tell you where any any directive is documented. ` StartLimitIntervalSec=` goes in Unit. The above question is about StartLimitInterval=. By using your local man pages, you can be sure you are checking the docs for the version you are actually running. – Mark Stosberg Aug 8 at 18:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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