2

Is there a way to run a script on startup as a user on Debian 7? My script is

screen -dmS name ./script.sh

So essentially I want to run a script on startup that would make a screen window and run a script in it

3

You can faff about with an elaborate sudo command in /etc/rc.local, but the best way is to use the user's cron table. cron has some nifty scheduling keywords including @reboot which will run the defined script or command when the system is rebooted.

So, as that user, run crontab -e, and add this line to the file:

@reboot screen -dmS ScreenName /path/to/your/script.sh
-1

If you mean when you start the desktop environment then odds are you are using GNOME and this may help you at least get an idea of what to look for.

http://linuxandfriends.com/how-to-add-startup-programs-in-gnome-3/

Ok so from the comments what you want is something to run every time a terminal session is started.

A good place for this is in the user's ~/.profile, or in the /etc/profile if you want it to happen for all users.

  • No it's a server actually – Tundral Oct 14 '16 at 19:25
  • Then what do you mean by screen window? That was suggesting to me a window environment. Did you mean a process that starts when the server boots up? – Rob Oct 14 '16 at 19:50
  • Is session the right term then. I want it to make a screen session which I can attach to later if I need to. All this will be done through SSH – Tundral Oct 14 '16 at 20:05
  • Ok then add it to you .profile in your home it gets sourced every time you open a terminal be it on the box or through ssh. – Rob Oct 15 '16 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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