Posted On January 12, 2021

Linux: How to Add a Line into Crontab from Command Line

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: How to Add a Line into Crontab from Command Line

The easy method:

newline=@reboot /usr/bin/numlockx
(crontab -l && echo "$newLine") | crontab -

Alternative (longer version) of adding a line to crontab:

crontab -l > tempCron # copy crontab to a new file
echo "$newLine" >> tempCron #echo new cron into cron file
crontab tempCron # Replace crontab with tempCron
rm tempCron

Original (manual) version of installing numlock:

sudo crontab -e
### add this line ###
echo "@reboot /usr/bin/numlockx" >> /usr/bin/crontab

Leave a Reply

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

Related Post

A Few Todos while Securing Apache Server

- Install mod_security - Set expose_php = Off in php.ini - Set SecResponseBodyAccess Off in…

Run Memory Tester On Ubuntu 20.04

GNU Grub 2.04 does have memtest86+ that could be used to perform RAM load tests.…

Linux: MySql Docker Container – Export database

# Set VariablessqlContainer="mysql-server"userName=bruceleepassword=chucknorrisdatabaseName=kimconnect# Run mysql inside containerdocker exec -it  $sqlContainer mysql -u$userName --password='$password'show databases;# Execute mysqldumpdocker exec $sqlContainer /usr/bin/mysqldump…