cron @reboot jobs race with setup of files under /sys
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cron (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
It looks like @reboot cron jobs run before /sys is fully populated. This is super-unexpected and very bad,
since the desire and expectation for things in this slot is pretty much always going to be to do something
"last" in the boot process. The user will have something they've discovered they have to do and now they
want to make it automatic *exactly as if they did it manually every boot*.
The evidence of the problem:
I have the caps-lock-
SHELL=
PATH=
@reboot /home/bkerin/
When run from cron, my script would die the first time it tried to read the
/sys/class/
to be to just wait in the script until the file shows up:
# Max Brightness File
my $mbf = '/sys/class/
# Current Brightness File
my $cbf = '/sys/class/
# Because it looks like the contents of /sys aren't all entirely populated
# before @reboot cron jobs run, since without these (or one or the other
# of themn anyway) the first cat below fails when we're invoked from reboot
# (but not otherwise).
while ( not -r $mbf ) { sleep 0.1; }
while ( not -r $cbf ) { sleep 0.1; }
# Max Brightness
my $mb = `cat $mbf`;
$? == 0 or die;
chomp($mb);
From this behavior I conclude that the @reboot cron job races with setup of files under /sys. For the reasons mentioned above this should be fixed.
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: cron 3.0pl1-137ubuntu3
ProcVersionSign
Uname: Linux 6.2.0-36-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: ubuntu:GNOME
Date: Thu Nov 9 11:11:14 2023
InstallationDate: Installed on 2023-11-04 (5 days ago)
InstallationMedia: Ubuntu 22.04.3 LTS "Jammy Jellyfish" - Release amd64 (20230807.2)
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: cron
UpgradeStatus: No upgrade log present (probably fresh install)