Run a script at startup as a user
5,373
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
Related videos on Youtube
Author by
Tundral
Updated on September 18, 2022Comments
-
Tundral over 1 year
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
-
Tundral over 7 yearsNo it's a server actually
-
Rob over 7 yearsThen 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?
-
Tundral over 7 yearsIs 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
-
Rob over 7 yearsOk 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.