Cronjob

  • Automated Let's encrypt + Jenkins ssl renewal script with cron

    Create the script Create a file named renew-ssl-jenkins.sh anywhere accessible and enter the code below: #!/bin/bash # change password value to your password SSLPASS=MyPassword123 sudo service apache2 stop || true certbot renew || true cd /etc/letsencrypt/live/mysite.com rm /var/lib/jenkins/jenkins.jks openssl pkcs12 -inkey privkey.pem -in fullchain.pem -export -out keys.pkcs12 -password pass:$SSLPASS || true keytool -importkeystore -srcstorepass $SSLPASS -deststorepass $SSLPASS -noprompt -v -srckeystore keys.pkcs12 -srcstoretype pkcs12 -destkeystore /var/lib/jenkins/jenkins.jks || true sudo service jenkins restart || true sudo service apache2 start || true Execute the script every month using cron Crontab entry: ... 0 1 1 * * ~/renew-ssl-jenkins.sh > /var/log/renew-ssl-jenkins.log ...    
  • Run Drupal 8 Drush and Cronjob with Crontab

    Run crontab in your terminal root@yoursite:~# crontab -e This will open a text editor where you can set the cron timings and commands. Create a new entry like below: 0 1 * * * /var/www/html/drupal8-project/vendor/bin/drush --root /var/www/html/drupal8-project/web/ core-cron -v > /var/log/drupal-8-cron.log This will run the drush that will call drupal 8 cronjob everyday at 1am and create a log file named "drupal-8-cron.log"