crontab add line command code example
Example 1: bash add new line to crontab
#!/bin/bash
line="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$line" ) | crontab -u userhere -
Example 2: how to edit crontab in linux
Step 1 : crontab -e
Step 2 : Select your prefered editor for the file.
Steo 3 : Add the command that you want to execute from cron and save that file.
Example : 1 0 * * 0 rm /home/jones/*.log > /dev/null 2>&1
Step 4 : check if cron is activate using command
crontab -l