[CentOS] Running a command at startup

Robert Moskowitz rgm at htt-consult.com
Thu Dec 13 21:13:46 UTC 2018


Thanks,

I will study this...

On 12/13/18 2:38 PM, Kenneth Porter wrote:
> --On Wednesday, December 12, 2018 7:04 PM -0500 Robert Moskowitz 
> <rgm at htt-consult.com> wrote:
>
>> So can someone point me to how to make this into a simple systemd 
>> service?
>
> I'd first create a utility script (untried code!) like this:
>
> /usr/local/sbin/BlueLedFunction.sh
>
> #!/bin/sh
> echo "$1" > /sys/class/leds/blue\:heartbeat/trigger
>
> Then I'd create /etc/systemd/system/BlueLedOff.service with 
> appropriate sections to invoke that script with "none" as an argument 
> and to run in your desired runlevel. (Take a look at the examples in 
> /lib/systemd/system.) Then issue this to have it run at startup:
>
> systemctl enable BlueLedOff
>
> Note that custom unit files go in /etc/systemd/system to avoid having 
> them overwritten by distro updates. You can customize existing unit 
> files by either copying them from /lib/systemd to /etc/systemd or you 
> can override single settings with specially-named subdirectories in 
> /etc/systemd/system. See the unit file documentation for details. 
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos
>




More information about the CentOS mailing list