Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 3557

Beginners Questions • [Software] How do I run a script at startup?

$
0
0
Before I continue, I want to say, many thanks for the able assistance being provided. I am learning stuff. :)

OK, I shut the laptop down for a couple days while other life priorities took precedence. But I'm back.

When I started up the laptop, I now see that the "run-at-startup.sh" script, specified by the startup.service file has run twice, about a half minute apart.

So I venture into the /etc/systemd/system directory, and see my original startup.service file. (looks like I need to enter systemd to the browser spell check ...)

I also see a link in the /etc/systemd/system/multi-user.target.wants directory back to the startup.service file mentioned above.

OK, is the reason I am seeing two runnings of the run-at-startup.sh script due to one time being run in single-user mode, and the second time when Debian switches to multi-user mode?


I tried changing the Type to oneshot, i.e.,

===

[Service]
Type=oneshot
ExecStart=/bin/sh /usr/local/sbin/run-at-startup.sh

===

But I still see two runnings of the script..

I need it to run only once.

What should I look at next?

Also, as requested earlied, here's the status ...

===

# systemctl status startup.service
○ startup.service - Run the run-at-startup.sh script systemd service.
Loaded: loaded (/etc/systemd/system/startup.service; enabled; preset: enabled)
Active: inactive (dead) since Tue 2025-02-04 18:12:12 EST; 5min ago
Process: 651 ExecStart=/bin/sh /usr/local/sbin/run-at-startup.sh (code=exited, status=0/SUCCESS)
Main PID: 651 (code=exited, status=0/SUCCESS)
CPU: 19ms

Feb 04 18:12:10 channels systemd[1]: Starting startup.service - Run the run-at-startup.sh script systemd service....
Feb 04 18:12:12 channels systemd[1]: startup.service: Deactivated successfully.
Feb 04 18:12:12 channels systemd[1]: Finished startup.service - Run the run-at-startup.sh script systemd service..

===

Note that the "exit 0" is intended. The script runs a command or two or three, then exits witha return code of 0.

Statistics: Posted by diningroom — 2025-02-04 23:22 — Replies 5 — Views 222



Viewing all articles
Browse latest Browse all 3557

Trending Articles