定时下载快速精密星历

来源:互联网 发布:淘宝旺旺代码生成器 编辑:程序博客网 时间:2024/04/27 15:59

采用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

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 7月1日本地流量怎么办 装电池的弹簧生锈了怎么办 电器被电池碱了怎么办 车辆被交警拖走怎么办 香烟熏的眼睛疼怎么办 想在中牟住5天怎么办 腰弯了直不了怎么办 自考科目停考了怎么办 把wlan密码忘了怎么办 滕州不给报新婚怎么办 体内锁水能力差怎么办 别人说你人品差怎么办 面对没素质的人怎么办 遇到很坏的室友怎么办 餐饮员工与顾客发生矛盾怎么办 新员工老员工出现矛盾怎么办 手机移动4g网慢怎么办 碰到素质低的老公怎么办 小孩做事拖拉 没时间观念怎么办 execl表中日期加3.5怎么办 狗狗喜欢咬人怎么办 烧烤一顿吃多了怎么办 派派背包食物不足怎么办 未转变者下不了怎么办 小升初户籍与房产不一致怎么办 小孩在外地读书怎么办计生证明 泉州居住证要半年小孩读书怎么办 孩子上学有兰山户口没有房产怎么办 培训机构跑路了怎么办 报的培训班跑路怎么办 巡视组举报后会怎么办 巡视组交办不办怎么办 分手以后还要不要联系忘不了怎么办 父母穷且不上进怎么办 惹父母生气了该怎么办 小孩戒奶不吃奶粉怎么办 孩子听不进去话怎么办 异性好朋友喜欢自己亲吻自己怎么办 对方对你反感了怎么办 家长偷看孩子日记老师怎么办 儿子与父母相冲怎么办