1

I have several applications that weren't configured to start up automatically. I am trying to figure out a way for those services to start up automatically after a reboot.

Eg. This is one command used to start one of the applications, how do I make this into a cron job. I guess the first thing will be to stop the service after reboot then restart it.

sh /opt/activiti/tomcat/bin/./startup.sh & disown

sh /opt/activiti/nohup ./start-activiti.sh > /dev/null 2>&1 & disown

I once tried @reboot sh /opt/activiti/tomcat/bin/./startup.sh & disown which didn't work.

Any thoughts?

  • This is (almost surely) irrelevant to your problem, but you never need to say something/./another_thing; just say something/another_thing. – G-Man Says 'Reinstate Monica' May 2 '18 at 2:32
  • 1
    Cron is for scheduled tasks, not event-based tasks. Why aren't you configuring a systems service for your apps? – MikeA May 2 '18 at 4:42
  • I'm pretty sure you wouldn't need the & disown, since Tomcat daemonizes by itself, and if the Startup.sh has the x bit set, you don't need the sh either. – Ulrich Schwarz May 2 '18 at 5:44
  • Was this in the global crontab /etc/crontab or your user crontab? – Ulrich Schwarz May 2 '18 at 5:44
  • @MikeA the cicd guys didnt configure the application to start automatically after reboot. they are now gone and I am trying to be proactive to find other means of doing it – bonafideaf May 2 '18 at 15:27
0

I wrote a bash script with the start command & stop command, added it to the /etc/init.d dir then used chkconfig to set the run levels. Works like a charm.

| improve this answer | |
0

I suggest you try the following. It seems like the reboot directive you added to crontab was not correct:

@reboot sh /opt/activiti/tomcat/bin/./startup.sh & disown

Try changing it to:

@reboot /opt/activiti/tomcat/bin/startup.sh & disown

This will make the startup.sh file located in /opt/activiti/tomcat/bin execute using the program you give it at the top of the script. Meaning, if you type:

/bin/bash

Inside your script, this will be the program that will execute the script.

Hope it helps

| improve this answer | |

Your Answer

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

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