Crontab Ubuntu?


#1

Hi I am running Ubuntu as webserver hosting with Sentora as Hosting Panel, and I have edited the crontab to update the certs auto, but It dosent seams to work :frowning:

My Crontab looks like this (/etc/crontab):

/etc/crontab: system-wide crontab

Unlike any other crontab you don’t have to run the `crontab’

command to install the new version when you edit this file

and files in /etc/cron.d. These files also have username fields,

that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

m h dom mon dow user command

17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
@monthly /root/letsencrypt/letsencrypt-auto certonly --webroot -w /etc/sentora/panel -d control.jonathannet.dk && service apache2 reload

I cant see any files in the /etc/cron.monthly folder, and then I type anacron in a terminal it says:

The program ‘anacron’ is currently not installed. You can install it by typing:
apt-get install anacron

Should I Install anacron to get it work first?

Kind regards
Jonathan


#2

Can you include your pasted text within triple single quotes ( ` ) it would make it much easier to read.

I assume your file is;

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
@monthly /root/letsencrypt/letsencrypt-auto certonly --webroot -w /etc/sentora/panel -d control.jonathannet.dk && service apache2 reload
#

Can I ask first what you want to achieve ? I assume you want your certificate to renew automatically when it’s within 30 days of renewal. If so, I’d use a different command and use the “renew” option in certbot ( the new name for the letsencrypt client). That way you can also run it on a daily basis and it will take care of things much better.

If you want to edit the cron, rather than manually editing that file, I’d suggest using “crontab -e” to edit the correct crontab


#3

Nice thx ill just put that command in the crontab then :slight_smile:

So now I have this in my crontab:

17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
0 23 * * * /root/letsencrypt/letsencrypt-auto renew && service apache2 reload

It this right if it should run every day at 23.00? :slight_smile:


#4

I’m not sure if you can skip the user (I’d guess no), so the line should probably be:
0 23 * * * root /root/letsencrypt/letsencrypt-auto renew && service apache2 reload

I’d recommend running /root/letsencrypt/letsencrypt-auto renew --dry-run once manually to make sure renewal is going to work.


#5

Seems to be working now, thanks for help :slight_smile:


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.