The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 1,762     Votes:  4 
Tags: init.d   init  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

URL: https://askubuntu.com/q/840847
Title: How to execute script file at startup without using any commands like ln -s or any other to be executed at first?
ID: /2016/10/23/How-to-execute-script-file-at-startup-without-using-any-commands-like-ln-s-or-any-other-to-be-executed-at-first_
Created: October 23, 2016
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Interesting question. Thanks for pointing out files in /etc/rc0.d you learn something new every day!

Create directory to drop your scripts into

First you need to create a directory of scripts you want automatically run at startup. I would suggest creating it within /usr/local/bin but it can be anywhere:

sudo mkdir /usr/local/bin/startup-scripts

Modify rc.local to run all your scripts

Then type gksu gedit /etc/rc.local to edit the startup script that has sudo powers.

Before the last line that says exit 0 copy and paste these lines:

for SCRIPT in /usr/local/bin/startup-scripts/*
do
	sudo chmod +x $SCRIPT ``` 
$SCRIPT ```
done

Optionally, for every script in the startup-scripts directory, I would put in something like:

echo "running script xyz within /usr/local/bin/startup-scripts"

as this message will appear in /var/log/syslog file and document your system setup.

⇧ Nautilus hard-sorts by modification-date, driving me insane How do I change permissions so I can edit the PAM password file?  ⇩