I would like to preserve the battery on my laptop by limiting how much it gets charged.
There is a file (/sys/devices/platform/lg-laptop/battery_care_limit) with a value of 100. I can run command
echo '80' | sudo tee /sys/devices/platform/lg-laptop/battery_care_limit
I have to run this command at every reboot.
I have tried adding it via crontab -e but it doesn't work.
How do I get this command to run automatically at every reboot?
Additional information posted as an answer
thanks for the reply.
This works:
@reboot echo 80 > /home/myuser/test.txt
Tried and failed all the following:
@reboot echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit
@reboot sudo echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit
@reboot sleep 60 && echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit
@reboot sleep 60 && sudo echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit
At least the command is being attempted.
journalctl -b | grep echo
returns:
CRON[1041]: (myuser) CMD (sudo echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit)
CRON[1045]: (myuser) CMD (sleep 60 && sudo echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit)
echo 80 > /home/myuser/test.txt
in your cron job to confirm cron is working. You don’t need the tee command because cron doesn’t output to STDOUT. You could trysudo echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit
and trouble shoot from there – PonJar Dec 31 '22 at 09:46sudo
and nothing will be written to the file after>
that way as it need elevated permissions ... Please see: https://www.gnu.org/software/bash/manual/html_node/Redirections.html – Raffa Dec 31 '22 at 13:19