How to Create Cron Job to Adjust Time Through Linux NTP Server
Create Cron Job to Adjust Time Through Linux NTP Server
In Linux base operating system daemon "Cron" is used to schedule the task automatically. Cron is also known as "Cron Job". In more simple words Cron is a tool to run a job and all of the jobs have to create in Crontab file. Crontab is a combination of Cron and Table (Cron+Table). Every users can create its own "Cron Jobs" to run the task automatically. Administrative user "root" can restrict to the other users to create "Cron Jobs", means if Administrative user "root" add other user in below mention file then user unable to create Cron Jobs.
Cron Job is used to automate the process like synchronization of files, email message forwarding, automatic updates, run a specific task means adjust time with Linux NTP Server, data backup and many more.
Here we are creating a Cron Job to adjust time through CentOS Linux NTP Server in Oracle Linux 6.5 client machine. NTP stands for Network Time Protocol, it is a networking protocol that use for clock synchronization between the computer systems. The port of NTP "Network Time Protocol" is 123 and it is use User Datagram Protocol "UDP".
First create a script. you can create a script in any location. Here we are creating a script on directory "desktop" of user "root" because this script is being created by user "root".
Use command "cd" to enter in the directory "desktop", use command "ls" to list the current content in the directory and create the script "ntptime.sh" by use of editor "vi".
cd Desktop/lsvi ntptime.sh
Note: .sh is an extension of shell scripting file in Linux, it is used to create executable file in Bourne Shell.
#!/bin/bashntpdate -u 172.20.1.235
chmod 744 ntptime.sh
1 7 * * * /root/Desktop/ntptime.sh
Post a Comment