In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
Recently, the electricity in my home is unstable, and the power is often cut off all of a sudden. Although I have a notebook, I may not be able to get an incoming call. It won't be long before the SSD in my notebook will be compared.
So write a simple script, when the power is low, turn off the phone, and then check regularly with crontab or systemd timers.
For more information on how to use the crontab command, please refer to here: https://www.jb51.net/article/148575.htm
I won't say much. Let's take a look at the detailed introduction.
Check_shutdown.timer:
$cat / etc/systemd/system/check_shutdown.timer [Unit] Description=Check if battery is low every 10 details [timer] OnCalendar=*:0/10Persistent= true [install] WantedBy=timers.target
Check_shutdown.service:
$cat / etc/systemd/system/check_shutdown.service [Service] ExecStart=ExecStart=/home/jiajun/.xmonad/scripts/shutdown.py
Check_shutdown.py:
#! / home/jiajun/.py3k/bin/pythonimport psutilimport loggingimport osimport datetimebat = psutil.sensors_battery () logging.warn ("% s: battery status:% s", datetime.datetime.now (), bat) if bat.percent < 15:logging.warn ("gonna shutdown") os.system ("sudo shutdown-h now")
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.