easiest way to run bash file on startup centos 8

cdabc123

Supreme [H]ardness
Joined
Jun 21, 2016
Messages
4,522
looking for the easiest (not proper or best) way to run a bash file on server start up. The bash file requires network.

trying the rc.local or crontab method seem to have been depreciated in centos 8

Systemd seems like overkill and a pita for my application. I dont have a proper keyboard on this server and would rather not write a .service file.

Im going for minimal keystrokes to make this work.
 
Make a bash script and put it in...somewhere accessible at boot.

Create a systemd service file which, type=oneshot, OR type=notify, AND, requires=network-online.target, AND
ExecStart=[/path/to/executable/script]

or make a sysvinit script and use systemd's sysv generator. ;)
im getting a no such file or directory error when I try to make the service file
Any reason I should be getting this error when running

cat /etc/systemd/system/<name>.service

That should create the file provided it can navigate to that directory?

And I appreciate the resources but would like to stress I have minimal intention to learn every aspect of the service files. This is a one time use type thing.
 
Any reason I should be getting this error when running

cat /etc/systemd/system/<name>.service

That should create the file provided it can navigate to that directory?

And I appreciate the resources but would like to stress I have minimal intention to learn every aspect of the service files. This is a one time use type thing.
No, cat is a command used to concatenate two files or streams and output the result to stdout (by default, anyway). It does not create files.

You can use the touch command as you are trying to use cat, and that should work. (it's primary purpose is to update the timestamps on files, but it works fine for this, too)
 
As for the resources, they shouldn't be necessary for the most part, but they do include examples, and are useful if you know what you are trying to do, so I linked them just in case.
 
Back
Top