保存文件后,我无法在 Ubuntu 中编辑我的 crontab

保存文件后,我无法在 Ubuntu 中编辑我的 crontab

已编辑

为什么以下命令会导致crontab -e显示权限被拒绝错误?

/bin/sh /var/www/ers-api-proxy/backup.sh 1> /var/www/ers-api-proxy/log.txt 2> /var/www/ers-api-proxy/err.txt

在我运行此命令之前,Crontab 对我来说工作正常。

当它最初停止工作时,我恢复了我的 DO droplet,它又开始工作了。然后当我第二次运行上述命令时,同样的问题又发生了?

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# EDITOR=pico

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# crontab -e
pico: Permission denied
crontab: "pico" exited with status 1

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# export EDITOR

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# crontab -e
pico: Permission denied
crontab: "pico" exited with status 1

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# sudo crontab -e
/usr/bin/sensible-editor: Permission denied
crontab: "/usr/bin/sensible-editor" exited with status 1

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# export EDITOR=/usr/bin/sensible-editor

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# sudo crontab -e
/usr/bin/sensible-editor: Permission denied
crontab: "/usr/bin/sensible-editor" exited with status 1

root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 5 * * 2 /bin/sh /var/www/ers-api-proxy/backup.sh 1> /var/www/ers-api-proxy/log.txt 2> /var/www/ers-api-proxy/err.txt
root@ubuntu-s-1vcpu-1gb-sfo2-01:/var/www/ers-api-proxy#

编辑:顺便提一下,我刚刚重新登录 SSH,也出现了这个错误,我觉得之前没有出现过(但不是 100%)

-bash: /usr/bin/lesspipe: /bin/sh: bad interpreter: Permission denied

/bin/sh也是我添加到我的 cronjob 中的内容,这有关系吗?

编辑2:实际上,看起来有多个命令不再对我起作用了,即使我以 root 身份登录也是如此。以下是当我尝试运行 shell 脚本时发生的情况(之前运行正常)

tar (child): gzip: Cannot exec: Permission denied
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

相关内容