Skip to content

What is the best (KISS) way to make the OS executes my bash script on every boot

Creating a systemd-timer with OnBootSec option or systemd.service seem to me kind of overhead.

For example, I have added the line session optional pam_exec.so type=open_session seteuid /root/telegram_alert.sh into the /etc/pam.d/sshd and it does the job when somebody login to the server via ssh.

So is there any way to invoke my script on system boot? It is not hard to me create the systemd.service for this. But looking for a simplest way.

6 points4 comments
Open on Reddit
About this post
Posted
Archived
Score
6 · 88% up
Kind
Text
ID
o7s5bm

Author

11
posts
22
comments
0
media
View profile

4 comments

The simplest way is to create a systemd service.

31 points

Running things on boot is literally what services were made for. Just create the systemd service and have done with it.

But looking for a simplest way.

The only arguably complex thing about a systemd service is systemd itself. If you're using systemd already (which you are, given that you're using Arch), then the simplest option is to use a service.

18 points

The systemd service is actually the simplest way to do it

9 points

Overhead? Assuming you mean in writing it (because if it's running anyway then there's no added overhead there) a service could be just 5 lines. Each about 1/5th of the length of the length of the one-liner you posted for something else. (And much shorter than your question here.)

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.