碰到一个问题,我有一个重启firefox.sh脚本,手动运行正常,添加到系统crontab后无法执行

定时重启firefox脚本:

#!/bin/sh
export DISPLAY=localhost:1.0
cd /root
rm -rf ~/.vnc/*.log /tmp/plugtmp* > /dev/null 2>&1
killall firefox > /dev/null 2>&1
/usr/bin/firefox --new-tab http://xxx.com> /dev/null 2>&1

赋执行权限

chmod a+x /path/restart.sh

crontab -e  #编辑crontab

0 * * * *  root /path/restart.sh  #每个小时执行

查看crontab执行情况:

tail -f /var/log/cron

经过研究,发现在添加0 * * * *  root /path/restart.sh时,不用添加root,去掉脚本路径前的root用户解决~