[CentOS] Running a command at startup
Robert Moskowitz
rgm at htt-consult.com
Thu Dec 13 14:03:51 UTC 2018
On 12/13/18 8:17 AM, Jonathan Billings wrote:
> On Wed, Dec 12, 2018 at 09:43:56PM -0500, Robert Moskowitz wrote:
>> OK....
>>
>> I have had problems in the past with crontab parsing a command. Would I use:
>>
>> @reboot root echo none | tee /sys/class/leds/blue\:heartbeat/trigger
>>
>> ?
>>
>> Or do I have to make a script and run that?
> Since this is a crontab, you can use normal shell redirection:
>
> @reboot root echo none > /sys/class/leds/blue\:heartbeat/trigger
>
> in a file in /etc/cron.d/
>
> The 'echo foo | sudo tee' thing is what you do for people who are
> using sudo to echo output into a file -- so often people think they
> can do 'sudo echo none > /some/path' and will be surprised it doesn't
> work.
Thanks. This is my first encounter with 'tee'. I guess because I
rarely use sudo, and work in su if I need to do root things.
> I still think it makes sense to create it as a systemd unit.
>
Seems the better, long-term way to go, but right now I don't have time
to learn enough about making systemd unit files.
Thanks
More information about the CentOS
mailing list