简体   繁体   English

在shell中创建用户cron时出错

[英]Error creating user cron in shell

I'm using a shell script to deploy my server. 我正在使用Shell脚本来部署服务器。 I have this line: 我有这条线:

crontab -l | { cat; echo "0 0 0 0 0 some entry"; } | crontab -

How can I modify this line to run this cron as a system user called "test"? 如何修改此行以以称为“ test”的系统用户身份运行此cron? When I try this: 当我尝试这个:

APPUSER="test"
crontab -u $APPUSER -l | { cat; echo "/10 * * * * somepath/bin/python somepath/cron.py"; } | crontab -

I get this error: 我收到此错误:

no crontab for test                                                                                  
"-":0: bad minute                                                                                     
errors in crontab file, can't install.    

Where am I going wrong? 我要去哪里错了?

I think you must add a * before /10 to make it run every 10 minutes, and add -u $APPUSER to the last crontab call (to add it to $APPUSER's crontab). 我认为您必须在/ 10之前添加一个*,以使其每10分钟运行一次,并将-u $ APPUSER添加到最后的crontab调用中(以将其添加到$ APPUSER的crontab中)。 Something like: 就像是:

APPUSER="test"
crontab -u $APPUSER -l | { cat; echo "*/10 * * * * somepath/bin/python somepath/cron.py"; } | crontab -u $APPUSER -

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM