定时下载快速精密星历
采用linux的計劃任務工具cron。
簡單用法:
參考http://yaksayoo.blog.51cto.com/510938/162062/
1、查看當前用戶的計劃任務
crontab -l
2、添加或編輯計劃任務
crontab -e
-----------------------------------------------------------
它的命令 采用 5個執行時間參數,然后是執行的命令
5個時間參數:
5個字段對應的含義如下:
? * ? ? ???*??????? *????? ? *????? ? *
分鐘???? 小時?? 日期?? 月份??? 星期
------------------------
例如:
01 4-23/6 * * * csh /home/zhao/programs/gamit104/cron.sp3u > /dev/null 2>&1
這條計劃任務的含義是:
每天的UTC 3:01, 9:01, 15:01, and 21:01 執行?cron.sp3u命令,并把命令輸出到無底洞。
------------------?cron.sp3u文件內容如下-----------------
#!/bin/csh -f
# 6-hourly cron to download IGS ultra-rapid orbits from cddis
# The cron should run UTC 3:01, 9:01, 15:01, and 21:01
# Cron below is for Boston daylight savings time (our crons
# ? run on local time). ?The script test for UTC time and?
# ? delays as needed).
# 01 4-23/6 * * * csh /home/zhao/programs/gamit104/cron.sp3u > /dev/null 2>&1
#
set sp3_dir = /home/zhao/work/RealTime/sp3_files
#
cd $sp3_dir >&! /dev/null
if( ! -e cron_sp3u.log ) then
? echo `date` "Creating sp3 ultrapid download log" >! cron_sp3u.log
? echo "--------------------------------------------------------------" >> cron_sp3u.log
endif
#
# Get current UTC time?
set time = `date -u +"%Y %m %d %H %M"`
# Generate the name of sp3 file needed and see if we should
# wait for it to arrive (i.e., EST versus EDT).
set wait = `echo $time[4] | awk '{print int(($1-3)/6)*6-$1+3}' | awk '{if( $1 < 0 ) {print $1+6} else {print $1}}'`
#
# Generate the name of SP3 file needed
set wd = `doy $time[1] $time[2] $time[3]| head -2 | tail -n -1 | awk '{printf("%4d %d",$3,$7)}'`
# Normally $wait should 0 during EST and 1hr when EDT in effect (line below can have problems if delay is too long)
set sp3f = `echo $wd $time[4] $wait | awk '{if($3+$4-3 < 24 ) {printf("igu%4.4d%1d_%2.2d.sp3",$1,$2,$3+$4-3)} else {printf("igu%4.4d%1d_%2.2d.sp3.Z",$1,$2,$3+$4-3-24)}}'`
echo STATUS: `date +"%Y%m%d-%H%M"` : Getting $sp3f wait $wait hrs >> cron_sp3u.log
# See if we need to sleep
if( $wait > 0 ) then
? sleep ${wait}h
endif
# Try to download file from cddis
set pw = `whoami`@`hostname`
while ( ! -e ?$sp3f )
? ? ftp -ivn cddis.gsfc.nasa.gov <<! >&! /dev/null
user anonymous $pw
cd pub/gps/products/$wd[1]
ls $sp3f.Z
get $sp3f.Z
!
# ? Try to uncompress
? ? if( -e ?${sp3f}.Z ) then
? ? ? ?uncompress ${sp3f}.Z
? ? else
? ? ? ?echo STATUS: `date +"%Y%m%d-%H%M"` : Getting $sp3f wait 1 minute >> cron_sp3u.log
? ? ? ?sleep 1m
? ? endif
end
#
# Thats all
總結
以上是生活随笔為你收集整理的定时下载快速精密星历的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 会计软件属于什么计算机软件,会计核算软件
- 下一篇: 前端学习(2370):组件之间的通讯方式