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

1 Answer 1

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
5
  • the terminal must remain open, im using ubuntu 14.04, gnome-schedule is already installed May 5, 2017 at 4:54
  • this picture will show why i need it to remain open postimg.org/image/yi10jgvyd May 5, 2017 at 5: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 May 5, 2017 at 5:57
  • Not to pass the buck, but this question might help. askubuntu.com/questions/46627/…
    – Robby1212
    May 5, 2017 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? May 29, 2017 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .