How to schedule bulk cron jobs in Linux? Easy peasy

  1. Login as root user through SSH (I prefer putty)
  2. To view crontab entries execute following command:
    crontab -l
  3. To edit crontab directly you can use:
    crontab -e
  4. But for bulk editing it’s not really convinient, right? Instead, we’ll create editable file with all needed entries first and then load it to crontab.
    1. Prepare crontab entries in regular .txt. For WordPress Multisite Cron it will look something like this:
      1       0       *       *       *       wget -O '' >/dev/null 2>&1
      2       0       *       *       *       wget -O '' >/dev/null 2>&1
      3       0       *       *       *       wget -O '' >/dev/null 2>&1

      or you can use curl instead:

      1       0       *       *       *       curl -L -s '' >/dev/null 2>&1
      2       0       *       *       *       curl -L -s '' >/dev/null 2>&1
      3       0       *       *       *       curl -L -s '' >/dev/null 2>&1

      I wont explain here crontab syntax in details as there are loads of instructions you can easily find.

    2. Create file in desired directory (that’s my root in Centos):
      cat > /var/www/www-root/data/my_cron.txt
      This will create file and open it for editing at once.
      How to schedule bulk cron jobs in Linux? Easy peasy
      You can edit it right here ( ctrl-c to past prepeared lines, ctrl-d to save ) or even through FTP if it’s more convinient to you.
      Mind, that next step will replace all existing entries in your current crontab. So in order to preserve them, remember to add them to your my_cron.txt as well.
    3. Update crontab with new values:
      crontab /var/www/www-root/data/my_cron.txt
    4. List cron jobs to verify your crontab has been updated correctly:
      crontab -l

    Not that complicated, right?


    From now when it comes to cronjobs you won’t waste your time anymore adding them manually.
    Just have extra cup of coffee instead)
Share this stuff:

Leave a Reply

Your email address will not be published. Required fields are marked *