临时执行定时任务
at
精度只有一分钟
安装
sudo apt install at
执行定时合集
echo "sudo systemctl suspend" | at 23:00 2025-04-05
echo "sudo systemctl suspend" | at 23:00
echo 'export DISPLAY=:0; export XAUTHORITY=/home/x/.Xauthority; notify-send "定时任务测试" "任务已执行!当前时间:$(date "+%Y-%m-%d %H:%M:%S")"' | at now + 1 minutes
echo 'xxx' | at now + 1 hours
上面命令中
DISPLAY
指定显示的屏幕,XAUTHORITY
指定认证密钥文件
查看已有计划
atq
取消指定编号计划
atrm 1
systemd
用到时再说
crontab
用到时再说