linux创建定时任务

133 阅读1分钟

预期创建的定时任务为:非root用户执行的脚本

step1:

切换到指定用户

例:su sonar

step2:

查看用户的定时任务

crontab -l

step3:

为当前用户创建定时任务,没有定时任务会直接创建一个文件

crontab -e

加入指令

*/1 * * * * /root/sonar/sonarqube-8.5.1.38104/bin/linux-x86-64/./sonar.sh start >> /web/hellotest1.txt

备注:此指令/root/sonar/sonarqube-8.5.1.38104/bin/linux-x86-64/./sonar.sh start需为正常可执行的指令

参考