change letsencrypt certbot run time - cron

I have setup certbot for letsencrypt key renewal. This works.
When i check my logs at /etc/log/letsencrypt i see it runs twice a day.
Somewhere around midnight and somewhere around noon.
I would like to run it only once a day somewhere in the early morning.
To get control over the running of certbot i removed all entries from my cronjobs. But unexpectedly it still runs.
So how is certbot started?
Extra info:
when i run a script to show all cronjobs i get this:
(script: How do I list all cron jobs for all users? )
mi h d m w user command
0 3 * * 1 root /usr/bin/rsnapshot weekly
0 */4 * * * root /usr/bin/rsnapshot hourly
16 10 * * * root test -x /etc/cron.daily/popularity-contest && /etc/cron.daily/popularity-contest --crond
25 6 * * * root /etc/cron.daily/apache2
25 6 * * * root /etc/cron.daily/apt-compat
25 6 * * * root /etc/cron.daily/aptitude
25 6 * * * root /etc/cron.daily/automysqlbackup
25 6 * * * root /etc/cron.daily/bsdmainutils
25 6 * * * root /etc/cron.daily/dpkg
25 6 * * * root /etc/cron.daily/exim4-base
25 6 * * * root /etc/cron.daily/logrotate
25 6 * * * root /etc/cron.daily/man-db
25 6 * * * root /etc/cron.daily/mlocate
25 6 * * * root /etc/cron.daily/ntp
25 6 * * * root /etc/cron.daily/passwd
25 6 * * * root /etc/cron.daily/popularity-contest
25 6 * * * root /etc/cron.daily/tomcat8
30 2 1 * * root /usr/bin/rsnapshot monthly
30 3 * * * root /usr/bin/rsnapshot daily
47 6 * * 7 root /etc/cron.weekly/man-db
the file from certbot i found was certbot in /etc/cron.d
it contained this line:
#0 4 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew
which i commented out (with the #).
my system is debian:
Debian GNU/Linux 9

I use certbot with Ubuntu 16.04 + nginx
There are two places to check jobs related to Certbot
1) /etc/cron.d/certbot
here you have
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew && nginx -s reload
2) systemd timer
run commnad:
$sudo systemctl list-timers
and see output
Sun 2018-07-08 00:46:59 EEST 7h left Sat 2018-07-07 12:36:26 EEST 4h 51min ago certbot.timer certbot.service
then
3)
go to check file that control time when systemctl run Certbot
/etc/systemd/system/timers.target.wants/certbot.timer
that is symbolic link for
/lib/systemd/system/certbot.timer
Pay attention to this lines that define times + random seconds (set a random time for purpose to don't stress simultaneously letsencrypt servers)
OnCalendar=--* 00,12:00:00
RandomizedDelaySec=3600

Related

ESXi | Persistent Cron job | /etc/rc.local.d/local.sh writing directory to cron file

I am trying to create a persistent cron job (i.e. one that survives reboot). I have followed this guide:
https://virtuallyvtrue.com/2019/03/29/shell-script-to-automatically-power-on-a-specific-vm-which-is-powered-off-vm/
I created a shell file in this directory.
/vmfs/volumes/datastore1/power-off.sh
I've updated the root cron file:
/var/spool/cron/crontabs/root
#min hour day mon dow command
1 1 * * * /sbin/tmpwatch.py
1 * * * * /sbin/auto-backup.sh ++group=host/vim/vmvisor/backup.sh
0 * * * * /usr/lib/vmware/vmksummary/log-heartbeat.py
*/5 * * * * /bin/hostd-probe.sh ++group=host/vim/vmvisor/hostd-probe/stats/sh
00 1 * * * localcli storage core device purge
*/10 * * * * /bin/crx-cli gc
00 0 * * * /vmfs/volumes/datastore1/power-off.sh
I edited the local.sh file to write the cron job and make it persistent.
/etc/rc.local.d/local.sh
Contents of local.sh
/bin/kill $(cat /var/run/crond.pid)
/bin/echo ‘00 0 * * * /vmfs/volumes/datastore1/power-off.sh’ >> /var/spool/cron/crontabs/root
crond
When the system reboots, a new cron job entry is created, but it appears to be using the time/date '*' as wildcards and is dumping the directory structure into the cron file:
#min hour day mon dow command
1 1 * * * /sbin/tmpwatch.py
1 * * * * /sbin/auto-backup.sh ++group=host/vim/vmvisor/backup.sh
0 * * * * /usr/lib/vmware/vmksummary/log-heartbeat.py
*/5 * * * * /bin/hostd-probe.sh ++group=host/vim/vmvisor/hostd-probe/stats/sh
00 1 * * * localcli storage core device purge
*/10 * * * * /bin/crx-cli gc
'00 0 altbootbank bin bootbank bootpart.gz bootpart4kn.gz dev etc include lib lib64 local.tgz local.tgz.ve locker opt proc productLocker sbin scratch store tardisks tardisks.noauto tmp usr var vmfs vmimages altbootbank bin bootbank bootpart.gz bootpart4kn.gz dev etc include lib lib64 local.tgz local.tgz.ve locker opt proc productLocker sbin scratch store tardisks tardisks.noauto tmp usr var vmfs vmimages altbootbank bin bootbank bootpart.gz bootpart4kn.gz dev etc include lib lib64 local.tgz local.tgz.ve locker opt proc productLocker sbin scratch store tardisks tardisks.noauto tmp usr var vmfs vmimages altbootbank bin bootbank bootpart.gz bootpart4kn.gz dev etc include lib lib64 local.tgz local.tgz.ve locker opt proc productLocker sbin scratch store tardisks tardisks.noauto tmp usr var vmfs vmimages /vmfs/volumes/datastore1/power-off.sh’
Are the startquote and endquote symbols required in the local.sh file? I can see that they're being inserted into the /var/spool/cron/crontabs/root file.
I'd really appreciate some help with this. I just need to power off my server at midnight and I can't believe it is this difficult.
The guide used incorrect syntax. It required " instead of ' in the /etc/rc.local.d/local.sh echo statement.
/bin/kill $(cat /var/run/crond.pid)
/bin/echo "00 0 * * * /vmfs/volumes/datastore1/power-off.sh" >> /var/spool/cron/crontabs/root
crond

Cronjobs not sending any e-mails

I have some cronjobs written on several servers using CentOS7 in combination with Plesk 18.
When I check my cron log I see that the cronjobs are started.
Even when I manually start the scripts I want to use they work, but for some reason when the crontab does it, nothing is happening.
For instance some of the cronjobs I have are:
MAILTO=support#shoptrader.nl
0 0 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/remove_files.sh
0 6 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/security_htaccess/security_htaccess.sh
15 7 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/backup_personal_files.sh
30 9 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_hacks/find_hacks.sh
*/5 * * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh
15 0 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/backup_templates_data/backup_templates_data.sh
If I check my log I see something like: Jan 14 09:30:01 web14 CROND[4402]: (root) CMD (sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh)
I've notified myself with e-mails and get this response
/var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh: line 12: php: command not found.
Which doesn't make sense, because PHP is working on the server.

run multiple task in crontab in the same time without delay

I have to run task which take time 3 or 5 minut
How to run multiple task in crontab -in same time ?
crontab -e
0 13 * * * /etc/rip_first_radio.sh
0 13 * * * /etc/rip_second_radio.sh
0 13 * * * /etc/rip_third_radio.sh
0 13 * * * /etc/rip_fourth_radio.sh
your crontab config is correct. But you can add add all into one script and run also.
vi main.sh
./etc/rip_first_radio.sh &
./etc/rip_second_radio.sh &
./etc/rip_third_radio.sh &
./etc/rip_fourth_radio.sh &
and add main.sh to cron.
0 13 * * * ./main.sh

My VPS restarting every hour

Hello my server is restarting every hour, where the problem ?
Centos 6.6 with WHM/Cpanel
This my cronjob
root#server [/etc/cron.d]# crontab -l
0 6 * * * /usr/local/cpanel/scripts/exim_tidydb > /dev/null 2>&1
30 5 * * * /usr/local/cpanel/scripts/optimize_eximstats > /dev/null 2>&1
2,58 * * * * /usr/local/bandmin/bandmin
0 0 * * * /usr/local/bandmin/ipaddrmap
18 23 * * * /usr/local/cpanel/scripts/upcp --cron
0 1 * * * /usr/local/cpanel/scripts/cpbackup
0 2 * * * /usr/local/cpanel/bin/backup
35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check
45 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_mailman_cache && /usr/local/cpanel/scripts/update_mailman_cache
30 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_db_cache && /usr/local/cpanel/scripts/update_db_cache
30 */2 * * * /usr/local/cpanel/bin/mysqluserstore >/dev/null 2>&1
15 */2 * * * /usr/local/cpanel/bin/dbindex >/dev/null 2>&1
15 */6 * * * /usr/local/cpanel/scripts/autorepair recoverymgmt >/dev/null 2>&1
*/5 * * * * /usr/local/cpanel/bin/dcpumon >/dev/null 2>&1
46 0 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl --notify
7,22,37,52 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1
42 4 * * * /usr/local/cpanel/3rdparty/bin/freshclam --quiet --no-warnings
Just looking at your cron jobs I can see that this job runs every hour, so that is a good place to start looking:
35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check
Also, this job runs twice an hour, but they happen so close together that it might appear to occur only once. Check it out next:
2,58 * * * * /usr/local/bandmin/bandmin
If you can, I would just comment out these 2 jobs for a few hours and see if that solves your problem. If it does then you know one of these is causing the reboot.

sh with crontab is not working in Centos

I am testing an sh script with crontab which simply creates a file
#!/bin/bash
PATH=$PATH:/bin:/usr/bin
TMP_FILE=/home/hmm/AppFlatForRent/i_am_running
touch "$TMP_FILE"
Now I want to run it on crontab and have used the following but failed
18 10 * * * sh /home/hmm/AppFlatForRent/hello.sh
Also this one
18 10 * * * usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
I am also trying this
23 12 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
23 12 * * * /home/hmm/AppFlatForRent/hello2.sh
Anyone knows whats the problem?
Solution:
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
This works!
Give the full path to the shell from cron starting with '/':
18 10 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
Or just leave the shell out and run the script directly if it is executable:
18 10 * * * /home/hmm/AppFlatForRent/hello.sh

Resources