linux总结

        工作进行阶段需要定时总结,才能不断进步。

1.crontab

定时处理任务的一个service,使用方法。

a.将cron配置文件拷贝到/etc/cron.d下面

b.执行service crond reload,重新加载cron任务,然后定时执行。

c.关于cron配置文件的写法有很多,在网上搜索了解即可。


2.日期处理

python日期处理:http://www.wklken.me/posts/2015/03/03/python-base-datetime.html#3-n 

python获取3个月前的日期:
three_months_before = datetime.datetime.now() - datetime.timedelta(days=90)
year = three_month_before.year
month = three_month_before.month
shell获取3个月前的日期:
year=`date -d '8 month ago' +%Y` (shell中的 ``''的区别)
month=`date -d '8 month ago' +%m`
echo $year,$month

3.shell脚本里面的"<"字符。
如果判断变量$a和变量$b的大小,应该这么写:
if [ "$a" \< "$b" ] 
注意:在[]结构中"<"需要被转义.( 注:大于小于号非常操蛋,基本不可用,还是用 -lt -gt

4.cp -rf强制覆盖确认问题: http://blog.itpub.net/519536/viewspace-596513/




你可能感兴趣的:(linux)