Crontab似乎执行脚本,但脚本不起作用

[英]Crontab seems to execute script, but script doesn't work


Running Rhel 7: I've got a script located at /root/backups/backup.py. It backs up my influxdb shards into swift.

运行Rhel 7:我在/root/backups/backup.py上有一个脚本。它将我的Influxdb分片备份到swift中。

It has a shebang in it. When I execute this command in my shell as root:

它有一个shebang。当我在shell中以root身份执行此命令时:

/root/backups/backup.py

it runs and functions correctly.

它运行正常,功能正常。

When I tell my cronjob to run it every 5 minutes, it appears as if it is running in the logs:

当我告诉我的cronjob每5分钟运行一次时,它似乎在日志中运行:

(root) CMD (/root/backups/backup.py)

However, it looks as if it didn't actually work for some reason. When I check, the backup file in swift that this should have created is not there. It is there when I run it from the shell.

但是,看起来好像它实际上并没有因某种原因而起作用。当我检查时,swift中应该创建的备份文件不在那里。当我从shell运行它时它就在那里。

I have no idea what the problem is. I've read many things online about the path in the crontab being incorrect. However, I have other cronjobs running that are in the exact same location i.e. /root/backups/ and they are also python scripts. They run once a minute or once every 5 minutes, and they run correctly. What gives?

我不知道问题是什么。我在线阅读了很多关于crontab中路径不正确的内容。但是,我运行的其他cronjobs位于完全相同的位置,即/ root / backups /,它们也是python脚本。它们每分钟运行一次或每5分钟运行一次,它们运行正常。是什么赋予了?

I don't need any sort of authentication to backup into swift as far as I know. I ssh to the VM, run the command in my console as root without any other authentication, and it works.

据我所知,我不需要任何形式的身份验证来备份到swift。我ssh到VM,在我的控制台中以root身份运行命令而不进行任何其他身份验证,它可以工作。

1 个解决方案

#1


0  

Figured it out.

弄清楚了。

It was having some sort of sudo access authentication error: https://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password

它有某种sudo访问身份验证错误:https://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo -without-A-密码


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/06/03/dbea5aff9023790b10810cf470fbb21.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com