1

so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications. This didn't work. I tried editing the .desktop file for the startup application to set Terminal=true. This made it open temporarily but shut it down. I tried editing .bashrc by adding the command bash /path/to/my/file.sh and it had the same effect. This seems like it should be really simple to do, even in linux, but I have tried lots of ways and had no success. I am on Ubuntu 14.something.

user2662920
  • 11
  • 1
  • 2
  • 1
    All of those methods should have worked (well, the .bashrc one is only on opening a Terminal; .profile would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with #!/bin/bash? – saiarcot895 Jul 03 '14 at 16:41
  • As @saiarcot895 you may forgot to give executable permissions to file. – Sudheer Jul 03 '14 at 16:43
  • You would be able to find out what filetype it is set to by typing in ls -la – ryekayo Jul 03 '14 at 16:49
  • Please [edit] your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users. – terdon Jul 03 '14 at 16:53
  • You can try this https://askubuntu.com/questions/704768/run-script-on-login-script-with-sudo-or-startup /etc/profile.d – dedunu May 29 '20 at 07:26

2 Answers2

0

Solution for Question --> "so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications."

Suppose path of your file is /home/foster/Desktop/script.sh

First make it executable by :

$ chmod +x /home/foster/Desktop/script.sh

Now just Add path of the script to file "/etc/rc.local" :

sh /home/foster/Desktop/script.sh
exit 0
vivekyad4v
  • 524
  • 1
  • 6
  • 12
0

When you set Terminal=true in the desktop file, the terminal window by default closes after the "the job has finished". An easy solution is to change your (terminal-) profile settings:

  • open a terminal window, choose Profile Preferences
  • choose "Title & Command" (at least that is what it is in Dutch, the second tab)
  • in the section "when the command has finished" choose "keep terminal window open"

And of course, like you did, in the desktop file, set Terminal=true

enter image description here

Jacob Vlijm
  • 83,767