Moxa UC-8410A-LX [42/86] Execute scheduled commands with cron

Moxa UC-8410A-T-LX [42/86] Execute scheduled commands with cron
UC-8410A Series Linux Software General Debian Package Usage
5-2
NTP Client
The UC-8410A-LX has a built-in NTP (Network Time Protocol) client that is used to initialize a time request to
a remote NTP server. Use
#ntpdate <this client utility> to update the system time.
ntpdate 192.168.1.97
hwclock –w
Visit http://www.ntp.org
for more information about NTP and NTP server addresses.
192.168.4.127 – PuTTY
moxa@Moxa:~$ sudo ntpdate 192.168.50.33
6 May 03:55:10 ntpdate[4511]: step time server 192.168.50.33 offset 78338115.278119
sec
moxa@Moxa:~$ sudo hwclock -w
moxa@Moxa:~$ sudo hwclock
Tue 06 May 2014 03:56:14 AM UTC -0.846314 seconds
NOTE
Before using the NTP client utility, check your IP and DNS settings to make sure that an Internet connection is
available. Refer to Chapter 2 for instructions on how to configure the Ethernet interface, and see Chapter 4 for
DNS setting information.
Execute Scheduled Commands with cron
The cron daemon reads /etc/crontab to retrieve scripts and other commands to be run at regularly
scheduled times.
The cron daemon wakes up every minute and checks each command listed in the crontab file to see if it should
be run at that time. Whenever cron executes a command, a report is automatically mailed to the owner of the
crontab (or to the user named in the MAILTO environment variable in the crontab, if such a user exists).
Modify the file /etc/crontab to schedule an application. Crontab entries follow the format below:
mm h dom mon dow user command
minute hour date month week user Command
0-59 0-23 1-31 1-12 0-6 (0 is Sunday)
For example, issue the following command if you want to launch a program at 8:00 every day:
#minute hour date month dow user command
* 8 * * * root /path/to/your/program
Every column in a crontab entry must be marked with a character. The asterisk indicates “every possible unit,”
so that setting an asterisk in the day-of-week column will configure cron to run the command on every day of
the week. If you wish to run a command “every X minutes” or “every X hours”, then use the format */X.
Updating System Time and RTC
Take the following steps to use cron to update the system time and RTC:
1. Write a shell script named fixtime.sh and save it to the /home directory.
#!/bin/sh
ntpdate time.stdtime.gov.tw
hwclock –w
exit 0
2. Reset the access permissions for fixtime.sh
moxa@Moxa:~# chmod 755 fixtime.sh

Содержание

Скачать