You are not logged in.

#1 2023-01-12 06:54:01

lugge
Member
Registered: 2017-03-17
Posts: 38

Where to place a script running after boot bu before login

Hi there,

I've got a script which fetches some information from the internet, does some magic and then writes some values in a temp file for later use.
Obviously, because of the internet access, the script has some noticeable execution time.

What I want:
1) The script shall be executed automatically after boot is finished.
2) The script shall be executed before a specific user logs in. If a user logs in before the script is finished, nothing bad would happen.

Where can I place / link such a script?
I thought about using a systemd-unit (WantedBy=multi-user.target ), however, I think this would delay the boot process? This should be avoided.
/etc/bash.bashrc, .bash_profile, .bashrc and so on are executed after a user logs in, thus, not the right solution either.

Any ideas?

Offline

#2 2023-01-12 07:05:09

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Where to place a script running after boot bu before login

lugge wrote:

I thought about using a systemd-unit (WantedBy=multi-user.target ), however, I think this would delay the boot process?

Not unless other units are configured to wait until your unit has finished. Parallelism is a feature of systemd.

Reference: https://wiki.archlinux.org/title/System … work_is_up


Jin, Jîyan, Azadî

Offline

#3 2023-01-12 07:29:10

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Where to place a script running after boot bu before login

Another advantage of using systemd is that you can make your script depend on network-online.target so that it is only triggered once the network is up.

https://wiki.archlinux.org/title/System … work_is_up


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB