I have a systemd unit file that starts two completely separate processes, apache and tomcat (and before you comment on it, I know I should just make two separate unit files, but permissions on this server are locked down tight). When starting the service through an SSH session, everything starts and stops just fine. However, when the server reboots, only apache starts back up, with systemd claiming everything is fine. When I check the tomcat logs, it appears to have started, but the process just dies at some point.

What could be causing this difference in behavior? Does this service need to wait on something else before starting?

Unit file:

After=syslog.target network.target



Both scripts are wrappers that contain something like this:

/bin/su - opiusr -c "/home/opiusr/bin/start_tomcat -s" >> $LOG_FILE
/bin/su - opiusr -c "/home/opiusr/bin/start_apache -s" >> $LOG_FILE

And those scripts simply wrap the tomcat and apache start and stop scripts, with some extra logging.

EDIT: I've seen this answer that is quite similar: Systemd kills service immediately after start

I'm wondering if I can do something else, seeing as the system is pretty locked down. I have full edit access to the unit file, and the two scripts, just not the ability to create new services or touch system directories.

  • In all seriousness, ask the sysadmin for a second unit file. Weird kluges make a system more complicated and certainly do not enhance security. Even if you get this working, systemd will be unable to monitor the unit properly (e.g., the "is is still running?" check won't work). And you're stopped from using various unit options that can lock things down to increase security. – derobert Apr 12 '17 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.