On 27 Feb 2024 10:15 -0500, from g...@extremeground.com (Gary Dale):
> However when I add those lines to the root's crontab using # crontab -e as
> 
> @reboot /usr/sbin/modprobe brcmfmac
> @reboot echo 13b1 0bdc > /sys/bus/usb/drivers/brcmfmac/new_id
> 
> the second line fails. I get an e-mail stating "/bin/sh: 1: cannot create
> /sys/bus/usb/drivers/brcmfmac/new_id: Directory nonexistent"

Probably a timing issue. "@reboot" crontab entries execute fairly
early (I think it really means "when the cron daemon starts"), and
among crontab entries with the same execution time, I do believe that
execution order is unspecified and execution quite possibly is
parallelized.

Since redirection is done by the shell, and command invocation is also
done by the shell, if the two start executing at the same moment and
execute perfectly in parallel, it seems very likely that the shell
would conclude that the path into which you want to redirect stdout is
nonexistent before modprobe has even finished loading, let alone
finished loading the module.

If two commands must be executed in sequence, either set up the
crontab entries so that the execution times cannot conflict, or
separate the commands with semicolons:

@reboot /usr/sbin/modprobe brcmfmac; echo 13b1 0bdc > 
/sys/bus/usb/drivers/brcmfmac/new_id

In this case you might even want the second to execute only when the
first completes _successfully_, so:

@reboot /usr/sbin/modprobe brcmfmac && echo 13b1 0bdc > 
/sys/bus/usb/drivers/brcmfmac/new_id

_That said_, if you want to load a module on boot, the generally
recommended way these days is to add it to a *.conf file in
/etc/modules-load.d. See modules-load.d(5) for details. The old way
was to add it to the file /etc/modules.


> Anyway, that got me down the rabbit hole to try to find where the crontab
> file is.

Per-user crontabs are in /var/spool/cron/crontabs, or at least are in
Bookworm (and this has been the case for what feels like forever).
This is mentioned in the DIAGNOSTICS section of the crontab(1) man
page, as well as in the NOTES section of the cron(8) man page.

-- 
Michael Kjörling                     🔗 https://michael.kjorling.se
“Remember when, on the Internet, nobody cared that you were a dog?”

Reply via email to