S
S
SimBioT192017-03-14 13:25:14
linux
SimBioT19, 2017-03-14 13:25:14

Execute command with cron?

Hey!
The question is simple, but I still ask for help. Installed the letsencrypt
certificate and you need to add its update to cron . The manual command for renewal is:

sudo /var/www/ssl/letsencrypt/letsencrypt-auto certonly --renew-by-default 
--webroot -w /var/www/ssl -d example.com && sudo service nginx reload

How to register it in cron tasks?
For now, I'm doing something like this:
0 */12 * * * root /var/www/ssl/letsencrypt/letsencrypt-auto certonly 
--renew-by-default --webroot -w /var/www/ssl -d example.com && service nginx reload

I get the error bin/bash: root: command not found
How do I get cron to execute the command correctly?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Saboteur, 2017-03-14
@saboteur_kiev

In which crontab file are you writing it?
In the user's crontab file (which is crontab -e), there is no column for specifying the username, this is only for /etc/cron* files.

F
Fixid, 2017-03-14
@Fixid

0 */12 * * * sudo -u root /var/www/...

D
display: block, 2017-03-14
@qork

Without root.

V
Vlad Kravets, 2017-03-14
@rexido

Isn't it easier to add all this to the script?

#!/bin/bash
/var/www/ssl/letsencrypt/letsencrypt-auto certonly --renew-by-default --webroot -w /var/www/ssl -d example.com &

 service nginx reload

0 */12 * * * /path/to/script.sh

Y
Yuri Chudnovsky, 2017-03-14
@Frankenstine

Oh, these bicycle builders :)
https://habrahabr.ru/post/304174/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question