我有一个手动执行的脚本:
#!/bin/bash
mount -t cifs //192.168.138.18/Shared_Drive /mnt/share -o username=user,password=guest
但是sudo crontab -e
不执行它。我尝试过:
@reboot /home/user/startup.sh
@reboot sh /home/user/startup.sh
@reboot bash -l /home/user/startup.sh
@reboot /bin/bash /home/user/startup.sh
没有任何效果。许可证是:
-rwxr-x--x 1 user user
答案 0 :(得分:1)
crontab -e
不执行计划的命令,它将在编辑器中打开您的crontab规则文件
然后,cron
会自己按指定的时间表执行命令。 (如果规则编写正确。如果需要帮助进行检查,则包括cron规则。)
还要注意crontab
命令手册页中的内容
请注意,su(8)可能会使
crontab
感到困惑,并且如果您在su(8)内部运行,则为了安全起见,应始终使用-u
选项
所以您应该运行sudo crontab -u root -e