System Administration & Network Administration
nginx cron lets-encrypt certbot
Updated Tue, 28 Jun 2022 19:21:08 GMT

Nginx certbot cronjob not working

I have installed certbot with the nginx module. Today I noticed that the cron that is installed automatically did not work. The cronjob in question is


and the content was

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

I debugged the script

test -x /usr/bin/certbot
echo $?
test -x /usr/bin/certbot -a \! -d /run/systemd/system
echo $?

and looked at the man-page for test. \! does not seems to be a valid argument for the -a flag.

I was able to run the cronjob using

0 */12 * * * root test -x /usr/bin/certbot -a -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

My question is: what does the \! do and has it always been there?

I'm using

certbot 0.26.1
nginx version: nginx/1.14.0
Ubuntu 16.04.5


From man test:

both EXPRESSION1 and EXPRESSION2 are true

-a is a logical and

! negates the following expression, -d /run/systemd/system

So, this translates to:

IF /usr/bin/certbot exists and is executable AND NOT /run/systemd/system exists and is a directory.

The \ is just an escape so the crond doesn't interpret the ! directly.

As to why it is there ... you will have to ask the package maintainers. If this is reproducible it may be worthwhile to raise an issue in their bugtracker if the installation produces a nonworking result in your system.

Comments (1)

External Links

External links referenced by this document: