Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 如何使用shell脚本启用和禁用cronjobs_Bash_Shell_Cron - Fatal编程技术网

Bash 如何使用shell脚本启用和禁用cronjobs

Bash 如何使用shell脚本启用和禁用cronjobs,bash,shell,cron,Bash,Shell,Cron,我们希望启用/禁用以下crontab: 已经尝试禁用使用,看起来我清除了我的crontab:/: crontab -l | sed "/^[^#].*bash /home/scripts/mywork.sh/s/^/#/" | crontab - …并获得问题: sed: -e expression #1, char 16: extra characters after command 如何修复它 我是stackoverflow新手,请随意评论,这样我可以提高我的提问技巧。您必须在sed命令

我们希望启用/禁用以下crontab:

已经尝试禁用使用,看起来我清除了我的crontab:/:

crontab -l | sed "/^[^#].*bash /home/scripts/mywork.sh/s/^/#/" | crontab -
…并获得问题:

sed: -e expression #1, char 16: extra characters after command
如何修复它


我是stackoverflow新手,请随意评论,这样我可以提高我的提问技巧。

您必须在sed命令中转义“/”字符

sed "/^[^#].*bash \/home\/scripts\/mywork.sh/s/^/#/"
sed "/^[^#].*bash \/home\/scripts\/mywork.sh/s/^/#/"