-1

I have a script in a folder:

/home/ubuntu/jasperreports-server-cp-6.3.0/ctlscript.sh

I need this script to run every time the server starts. Usually the server shuts down on Friday evenings and starts on Monday morning. What do I need to do in order to make this happen?.

How I manually start the script:

I will ssh to the server, and then go to this location /home/ubuntu/jasperreports-server-cp-6.3.0

and then run ./ctlscript.sh* start command manually.

But I am unable to start this script at the server start on Monday automatically.

I tried using rc.local , and also creating a script in /etc/init.d, I did follow this but it didn't work either How do I run a script at start up?.

Does anyone have any other suggestions? Or is my procedure wrong?

Zanna
  • 70,465

1 Answers1

0

I solved it this time

First I created a runnable script

vi script.sh

at home location that is at /home/ubuntu (you can create it at any location,but remember you have to give the same location in crontab -e) and then added these lines to the file script.sh

#!/bin/sh
cd /home/ubuntu/jasperreports-server-cp-6.3.0
./ctlscript.sh start

(I have a parameter to use start , but for you it might be a different, so here it should be the command that you use manualy to run the script, in simile it should be the same as how you run the script manually)

and then saved it. now gave the file script.sh permission to exec using

chmod 700 script.sh

(You can give permissions based on your needs, all we need is the script to be give permission for execution)

And now opened crontab -e command, and added

@reboot sh /home/ubuntu/script.sh

so when my server reboots or starts , the script is run every time. it worked for me. thank you all