Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have made a .sh (which works) to run a mono program. How do I make it run every time I login? (and display in a terminal, not just run in background) Ubuntu server 12.04 with Unity desktop.

share|improve this question
add comment

6 Answers

if you kown how to handle crontab , add this line :

@reboot gnome-terminal -e "./dirtoyourscript/yourscript.sh"

if you don't know , execute the following commands to edit your crontab

EDITOR=gedit 
export EDITOR
alias editor=$EDITOR
crontab -e
share|improve this answer
add comment

Put your script in a file (we call it yourscript.sh) and make in executable:

#!/bin/bash
#put your script here
echo "Press enter to close"
read line

Then open /etc/rc.local file using a text editor:

sudo gedit /etc/rc.local

Finally add the following code in the rc.local just before "exit 0" command:

gnome-terminal -e "./dirtoyourscript/yourscript.sh"

exit 0

Have a nice time.

share|improve this answer
    
I would believe, /etc/rc.local runs before X does (and thus, even before the login greeter); which means /etc/rc.local is not appropriate for doing things "after login". –  sdaau May 4 '13 at 20:54
add comment
  • First make your script executable.
chmod +x /path/to/script
  • Open Startup Applications, from the cog menu present at the upper right corner.

Cog menu

  • Click on Add.

Startup Applications Dialog

  • Fill in all the details and click Add.

Add Startup Application Preferences

  • Logout and login back to check.
share|improve this answer
add comment

Go into the Startup Applications dialog, click Add, give it a name and in Command put

gnome-terminal -e yourscript.sh

You can check it works first by running gnome-terminal -e yourscript.sh from a terminal (it should then open another terminal).

share|improve this answer
add comment

You could use $HOME/.bashrc It is parsed and run like a script, every time bash starts. Bash is the default shell for Ubuntu.

I have a script that saves every command line I've used, like this:

$ tail -2 $HOME/.bashrc
/usr/local/bin/backup-historial.sh &
share|improve this answer
    
So I have to put my scirpt in .bashrc which is in /home? I tried this and it didn't work. –  jabelone May 6 '12 at 4:10
add comment

Yes you can start any script by navigating toSystem \ Preferences\ Sessions menu item and then just adding the command or the script you want to rin image

share|improve this answer
    
is this 12.04 ? it's unity in 12.04, not gnome 2 –  Prasad RD May 6 '12 at 3:41
    
sorry, I meant unity. –  jabelone May 6 '12 at 3:50
    
ok sorry for i took it for gnome. Well unity has its own preferences. The startup application in unity can be found at topbar as a drop-down menu option of power button, located before the shotdown options and all. –  ashutosh May 6 '12 at 3:53
    
thanks, i have tried doing that to no avail. –  jabelone May 6 '12 at 4:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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