English 中文(简体)
尽管试图从Stackover流程中找到不同的固定点,但还是没有工作
原标题:crontab not working despite trying different fixes from Stackoverflow

我试图做一些令人生畏的工作,但我看来说,这并不是说。 在ISO读过许多读物后,改变了这些内容:

  • I ve removed the sudos inside the crontab.
  • I ve added the full path of all the commands inside the crontab.
  • I ve restarted the cron job each time I ve changed it.

但是,它还没有发挥作用。

这是我目前的信条(我称之为“超级信条——e”,把它作为根基):

0 4 * * * /usr/bin/find /var/backups/mongobackups/ -mtime +7 -exec rm -rf {} ; > /var/log/log1.log
5 4 * * * /usr/bin/mongodump  --out /var/backups/mongobackups/`date +"%m-%d-%y"` --ssl --sslPEMKeyFile=/etc/ssl/mongo.pem --username <mymongoadminusername> --password <mymongoadminpassword> --authenticationDatabase=admin > /var/log/log2.log
30 4 * * * /opt/letsencrypt/certbot-auto renew > /var/log/log3.log
35 4 * * * /etc/init.d/nginx reload > /var/log/log4.log
40 4 * * * /bin/cat /etc/letsencrypt/archive/<mydomanin>/{fullchain1.pem,privkey1.pem} | /usr/bin/tee /etc/ssl/mongo.pem > /var/log/log5.log

我试图与这5个指挥部做的是:

  1. At 04:00. Remove all backups that are more than 7 days old.
  2. At 04:04. Backup all my mongodb databases.
  3. At 04:30. Try to renew my SSL certificate.
  4. At 04:35. Reload Nginx service.
  5. At 04:40. Update my mongodb.pem file with the new certificate.

It s important to say that each of these commands running from the shell one by one with sudo are working properly.

But from the cron the results are:

  1. 我不知道这一指挥是否在发挥作用。 记录单(log1.log)是空的。

  2. 它不工作。 没有建立后备部队。 尚未建立记录档案(log2.log)。

  3. 它似乎正在发挥作用。 记录档案(log3.log)显示,当你正确管理这一指挥时,标准产出是正确的。

  4. 它似乎正在发挥作用。 记录档案(log4.log)显示,当你正确管理这一指挥时,标准产出是正确的。

  5. 这似乎不可行。 mongo.pem案有正确的更新日期,但档案是空的。 文档的全链1.pem和Privkey1.pem有正确的内容,因此似乎存在“usr/bin/tee /etc/sl/mongo.pem”的问题。 尚未建立记录档案(log5.log)。

最后,陈词显示:

Nov 11 04:00:01 myservername CRON[31286]: (root) CMD (/usr/bin/find /var/backups/mongobackups/ -mtime +7 -exec rm -rf {} ; > /var/log/log1.log)
Nov 11 04:05:01 myservername CRON[31297]: (root) CMD (/usr/bin/mongodump  --out /var/backups/mongobackups/`date +")
Nov 11 04:05:01 myservername CRON[31296]: (CRON) info (No MTA installed, discarding output)
Nov 11 04:07:01 myservername CRON[31306]: (root) CMD (   test -x /etc/cron.daily/popularity-contest && /etc/cron.daily/popularity-contest --crond)
Nov 11 04:17:01 myservername CRON[31325]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Nov 11 04:30:01 myservername CRON[31353]: (root) CMD (/opt/letsencrypt/certbot-auto renew > /var/log/log3.log)
Nov 11 04:30:04 myservername CRON[31352]: (CRON) info (No MTA installed, discarding output)
Nov 11 04:35:01 myservername CRON[31393]: (root) CMD (/etc/init.d/nginx reload > /var/log/log4.log)
Nov 11 04:40:01 myservername CRON[31420]: (root) CMD (/bin/cat /etc/letsencrypt/archive/<mydomanin>/{fullchain1.pem,privkey1.pem} | /usr/bin/tee /etc/ssl/mongo.pem > /var/log/log5.log)
Nov 11 04:40:01 myservername CRON[31419]: (CRON) info (No MTA installed, discarding output)

如果我不错过“没有安装任何微型贸易安排,放弃产出”不是一个问题,因为它与通过电子邮件发送产出有关,我是否正确?

因此,任何人都能够告诉我,我的指控是错误的。

非常感谢!

最佳回答

我不知道我的指控是什么问题,但是如果我把所有这些指挥都放在文字上,并把这一文字放在 cr子里的话,那是起作用的。

文字(手稿):

#!/bin/bash

/usr/bin/find /var/backups/mongobackups/ -mtime +7 -exec rm -rf {} ; > /var/log/log1.log
/usr/bin/mongodump  --out /var/backups/mongobackups/`date +"%m-%d-%y"` --ssl --sslPEMKeyFile=/etc/ssl/mongo.pem --username <mymongoadminusername> --password <mymongoadminpassword> --authenticationDatabase=admin > /var/log/log2.log
/opt/letsencrypt/certbot-auto renew > /var/log/log3.log
/etc/init.d/nginx reload > /var/log/log4.log
/bin/cat /etc/letsencrypt/archive/<mydomanin>/{fullchain1.pem,privkey1.pem} | /usr/bin/tee /etc/ssl/mongo.pem > /var/log/log5.log

The crontab:

00 03 * * * <pathtomyscript>/myscript.sh

现在这项工作正在进行。

问题回答

阁下:

/usr/bin/mongodump -out /var/backups/mongobackups/ --ssl --slPEMKeyFile=/etc/ssl/mongo.pem --———— --authenticationDatabase=admin >/var/log/log2。

记录显示,你实际上正在运行:

页: 1

这是因为,在装饰中,有%是保留性质。 这是一条新路线。 你们需要从中逃脱,就象 %

作为文字管理的一种额外好处是,你可以决定哪些票价将用来作为传票的翻译。

在我的系统上,它通过干ash(/usr/bin/shs)而不是ash(/usr/bin/bash)进行指挥。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签