Cronjobs 不起作用,但命令有效

Cronjobs 不起作用,但命令有效

我必须在我的 cronjob 列表中发出命令。我用于mysql备份,一个用于目录cp命令。

当我运行命令时,它们起作用。但是当我运行以下命令时,出现错误:

run-parts /etc/cron.daily

错误:

cp: cannot create regular file 'dpkg.status': Permission denied
touch: cannot touch 'dpkg.status': Permission denied
savelog: could not touch dpkg.status
cp: cannot create regular file 'dpkg.diversions': Permission denied
touch: cannot touch 'dpkg.diversions': Permission denied
savelog: could not touch dpkg.diversions
cp: cannot create regular file 'dpkg.statoverride': Permission denied
touch: cannot touch 'dpkg.statoverride': Permission denied
savelog: could not touch dpkg.statoverride
/etc/cron.daily/logrotate: 6: /etc/cron.daily/logrotate: cannot create status.clean: Permission denied
/etc/cron.daily/logrotate: 7: /etc/cron.daily/logrotate: cannot create status.clean: Permission denied
mv: cannot stat 'status.clean': No such file or directory
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error switching euid to 0 and egid to 108: Operation not permitted
error: error creating output file /var/lib/logrotate/status.tmp: Permission denied
run-parts: /etc/cron.daily/logrotate exited with return code 1
start-stop-daemon: unable to set gid to 12 (Operation not permitted)
run-parts: /etc/cron.daily/man-db exited with return code 2
flock: cannot open lock file /run/mlocate.daily.lock: Permission denied
run-parts: /etc/cron.daily/mlocate exited with return code 66
cp: cannot create regular file 'passwd.bak': Permission denied
cp: cannot create regular file 'group.bak': Permission denied
cp: cannot open '/etc/shadow' for reading: Permission denied
cp: cannot open '/etc/gshadow' for reading: Permission denied
run-parts: /etc/cron.daily/passwd exited with return code 1

我的克朗:

0 6 * * * zip -rj /home/dan/Dropbox/$(date '+%Y%m%d%H%M%S')_bk.zip /home/dan/dan_portfolio/src/
0 6 * * * mysqldump -u 'danport' -p'I_CHANGE_THIS' danport_db > /home/dan/Dropbox/$(date '+%Y%m%d%H%M%S')_db.sql

答案1

逃避日期解决了我的问题。

\%Y\%m\%d\%H\%M\%S

相关内容