• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Adding to Crontab in Bash

January 10, 2019

Here’s a neat command to append a job to a crontab within a Bash script.

crontab -l | { cat; echo "0 1 * * * /dir/script.sh > /logs/script.cronlog 2>&1"; } | crontab -

crontab -l | { cat; echo "0 1 * * * /dir/script.sh > /logs/script.cronlog 2>&1"; } | crontab -

To validate, perform crontab -l to see if your changes are there.

crontab -l

crontab -l

Filed Under: Linux Tagged With: bash, cron, crontab

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023