Ubuntu Crontab

时间:2023-03-09 00:01:54
Ubuntu Crontab

Ubuntu启用Crontab

启动cron服务:

service cron start

如果需要设置为开机时自动启动,则执行

sysv-rc-conf --level 35 cron on

另外,ubuntu默认没有开启cron执行的日志的,需要做如下3步:

  • 修改rsyslog文件,将/etc/rsyslog.d/50-default.conf 文件中的#cron.*前的#删掉
  • 重启rsyslog服务service rsyslog restart
  • 重启cron服务service cron restart

Ubuntu 14.04 + 版本的cron中使用notify-send

#!/bin/sh

eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)"
notify-send $1

具体参见

然后编辑cron配置: crontab -e

0 * * * 1-5 sh /home/ronry/bin/cron-notice.sh 休息一下