当前位置:   article > 正文

ubuntu 用crontab 实现定时关机(解决权限不足问题)_crontab 权限不足

crontab 权限不足

Cron will work very well for this.

You need first to find the complete path to the shutdown command:

  1. a@ubuntu:~$ which shutdown
  2. /usr/sbin/shutdown

Knowing the path to the shutdown command, you can add the below line (with tweaks) to the end of /etc/crontab:

30 23 * * * root /usr/sbin/shutdown -h now

At 23:30 (11:30 PM), the kiosk will shut down. No matter what user is logged in, the shutdown command runs as root.

(If you don't want to use the global crontab, log in as root and use crontab -e. Use the same above syntax without the root).


Cron Format:

MM HH DD OO WW command

MM: Minute, 0-59
HH: 24-hour hour
DD: Day of month
OO: Month
WW: Day of Week (Sunday is 0, Monday is 1)
command: Self-explanatory

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/75588
推荐阅读
相关标签
  

闽ICP备14008679号