M
M
m5xim2020-08-27 11:45:11
linux
m5xim, 2020-08-27 11:45:11

Why is the command not working in cron?

Good afternoon.
There is ubuntu 20.04, in the root crontab (sudo crontab -e) added:

@reboot echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold

On reboot, the command works (added test output to the file), but the changes are not applied.
If you run the command in the terminal manually
echo 60 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold
then the changes will be applied. Strange, but I remember that I noticed this with other commands, perhaps during the '@reboot' hook the system is not fully initialized, or something like that. Who faced this, tell me the reasons

UPD: After transferring to /etc/rc.local (there was no file by default, who needs to google it) it worked, though the GUI has a delay after turning on the system, it still shows a charge for 2 minutes, and then it only updates (if you check through the terminal, then the value is set immediately)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Karasik, 2020-08-27
@m5xim

maybe during the '@reboot' hook the system is not fully initialized,

I think this is the reason.
Run in rc.local.

A
Adamos, 2020-08-27
@Adamos

There is no PATH in the cron.
Write the full paths to any command that you have "and manually executed."

V
Valdemar Smorman, 2020-08-27
@smorman

Because it is necessary to reload Cron:
sudo /etc/init.d/cron restart

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question