-1

I have to run a bash script on bootup which opens couple of terminals and runs some command in each terminal.

test.sh (My bash file)

#!/bin/bash

sleep 10

gnome-terminal --tab-with-profile="Default" -e 'bash -c '\''export TAB=1; mkdir /home/naman/Desktop/test_folder'\'  
  1. I have created a testjob.conf inside /etc/init/ :

testjob.conf (Upstart config file)

description "A test job file for experimenting with Upstart"
author "Naman Kumar"

start on runlevel [2345]

exec echo Test Job ran at  `date` >> /var/log/testjob.log

exec bash /home/naman/Desktop/test.sh

Now, the problem is testjob.conf is not able to run the test.sh file on bootup (or it runs it but does not create a folder test_folder). If I remove the last line from testjob.conf : exec bash /home/naman/Desktop/test.sh, everything works and when I do cat /var/log/testjob.log, I get the correct output but if the last line is there, cat /var/log/testjob.log does not give the latest output.

  1. I have also tried updating /etc/rc.local with : bash /home/naman/Desktop/test.sh but that also does not seem to be running the test.sh script on bootup

I am not sure whether they run the scripts but are not able to create the folder or they are not even able to run the script on bootup.

Note: I can not use System -> Preferences -> Startup Applications because I don't have any monitor, so the desktop application does not run. (I am running it on a Single Board Computer with no monitor).

Does anyone know what is the issue here and why is the test.sh script not running properly on bootup?

Thanks in advance.
Naman

Naman91
  • 1
  • 2
  • 2
    You "don't have a monitor", so "desktop application does not run", and you want to run `gnome-terminal`, a desktop application, not to say during sysvinit??? – Cong Ma Sep 15 '15 at 22:41

1 Answers1

0

Cong ma is pretty close on this. Sysvinit is for system level daemons. It has no idea for users. That means it doesnt have a way to interact with your window system (or gnome).

Further: without a monitor, what would you expect gnome-terminal to do? gnome-terminal would open up a terminal on the monitor: which you can't see.

What you should look at is taking your commands (date, etc) and putting them in /etc/rc.local and not trying to 'olay them into a different terminal or anything. Just literally run the commands there.

Marc Young
  • 3,854
  • 3
  • 18
  • 22