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

2 Answers 2


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.


That cron job is ridiculous. It does nothing but fail, precisely because it's installed on a systemd system. The logic is intended to not execute certbot when run on a systemd system, specifically when the directory /run/systemd/system exists.

It's not how you're supposed to run certbot renew on a systemd system. You're meant to use the systemd timer.

The cron job would make sense on an old Ubuntu system that used upstart instead of systemd. So it's not clear why Ubuntu package maintainers put it in the current package at all. It's not a standard part of certbot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.