按日期分割nohup日志文件

  1. 先创建一个shell 
#!/bin/bash
#coding:utf-8

date_=`date -d -1day +%Y%m%d`
source_='/app/push/go-push/src/nohup.out'
target_='/app/push/go-push/src/nohup'$date_'.out'

# step1.
cp $source_ $target_

# step2.
cat /dev/null > $source_

2. 执行命令crontab -e

把下面的定时器语句加入,并保存

0 0 * * *   cd /app/push/go-push/src/ && nohup sh nohup.sh &

3、执行下面的命令让定时器生效

    service crond restart 

猜你喜欢

转载自blog.csdn.net/anran186/article/details/90199592