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

CentOS 8: How to Only Apply Security Updates

[cuilo@test-box ~]# sudo yum --security update CentOS-8 - AppStream 12 kB/s | 4.3 kB 00:00…

Network Time Service for Centos 7

yum install -y ntp ntpdatesystemctl start ntpdsystemctl enable ntpdntpdate -u -s 0.north-america.pool.ntp.org 1.north-america.pool.ntp.org 2.north-america.pool.ntp.org 3.north-america.pool.ntp.orgsystemctl…

How to Install Selenium for Python on Windows or Linux

Windows # This error would occur if pip is not up to date PS C:\WINDOWS\system32>…
Other project: DragonCoin.com