0

If I open a terminal and run this in the terminal: source /home/deploy/script.sh

It will execute script.sh

command below is what i wrote in script.sh

cd /var/www/applikasi-siao/iClockServer && thin -e production -p 2345 -P tmp/pids/thin.pid -l logs/thin/log start

this command above must run in the same terminal and the terminal should stay open.

I created script.sh so when i open terminal and type source /home/deploy/script.sh it will run

cd /var/www/applikasi-siao/iClockServer && thin -e production -p 2345 -P tmp/pids/thin.pid -l logs/thin/log start

I need all of this processes run automatically every reboot without manually opening a terminal and typing source /home/deploy/script.sh

d a i s y
  • 5,511

1 Answers1

0

Cron/Cronjobs will allow you to automate the task above to after every restart HOWEVER, it won't leave a terminal window open.

For info on Cron you can look at the CronHowto: https://help.ubuntu.com/community/CronHowto

Also please mention what operating system you are using.

Crons are really quite interesting so I highly recommend reading into them but TLDR.

Open a terminal window.

Install Cron

sudo apt-get install gnome-schedule

After that has completed type

crontab -e

If the script requires administrative privileges use:

sudo crontab -e

And then at the bottom of the file add the following with the path being to where that script is.

@reboot /home/username/start_application.sh
Robby1212
  • 880
  • the terminal must remain open, im using ubuntu 14.04, gnome-schedule is already installed – Dimitri Guggenheim May 05 '17 at 04:54
  • this picture will show why i need it to remain open https://postimg.org/image/yi10jgvyd/ – Dimitri Guggenheim May 05 '17 at 05:08
  • i tried to use starting application. I wrote command on startup : [code]gnome-terminal -e 'bash -c "/var/www/applikasi-siao/iClockServer/script.sh; exec bash"' [/code]

    it started new terminal everyboot but it said thin command is not found, how can i change directory to /var/www/applikasi-siao/iClockServer before starting the thin - e bla bla bla

    – Dimitri Guggenheim May 05 '17 at 05:57
  • Not to pass the buck, but this question might help. https://askubuntu.com/questions/46627/how-can-i-make-a-script-that-opens-terminal-windows-and-executes-commands-in-the – Robby1212 May 05 '17 at 12:30
  • I tried that, but it run as root, i need to run the script as user (my username= deploy)...so is there anything u could think of? – Dimitri Guggenheim May 29 '17 at 07:15