免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1747 | 回复: 8
打印 上一主题 下一主题

求助:为什么没有文件生成 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-08-31 10:11 |只看该作者 |倒序浏览
Ubuntu系统,我定制了任务,任务能正常执行,但是就是粗体那句话没有产生结果,为什么呢?谢谢,怎么都想不明白啊

#!/bin/bash
mydate=`date -d yesterday`
name=`echo $mydate |awk '{print $3"/"$2"/"$6}'`
name4sed=`echo $mydate |awk '{print $3"\/"$2"\/"$6}'`
ndate=`date -d yesterday +%Y%m%d"`
grep $name /var/log/apache2/access.log  > /tmp/apaLog/"$ndate".log
cp /var/log/apache2/access.log /var/log/apache2/access.log.bak
sed -i "/$name4sed/d" /var/log/apache2/access.log

论坛徽章:
16
IT运维版块每日发帖之星
日期:2015-08-24 06:20:00综合交流区版块每日发帖之星
日期:2015-10-14 06:20:00IT运维版块每日发帖之星
日期:2015-10-25 06:20:00IT运维版块每日发帖之星
日期:2015-11-06 06:20:00IT运维版块每日发帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT运维版块每日发帖之星
日期:2016-04-15 06:20:00IT运维版块每日发帖之星
日期:2016-05-21 06:20:00综合交流区版块每日发帖之星
日期:2016-08-16 06:20:002015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-08-14 06:20:00
2 [报告]
发表于 2010-08-31 10:13 |只看该作者
手动执行有么

论坛徽章:
0
3 [报告]
发表于 2010-08-31 10:15 |只看该作者
回复 2# expert1


    手动执行有的

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
4 [报告]
发表于 2010-08-31 10:22 |只看该作者
自己先看看日志
* * * * * /test.sh >> /test.log 2>&1

论坛徽章:
0
5 [报告]
发表于 2010-08-31 10:33 |只看该作者
回复 4# Shell_HAT


    按照您的指导,得到的结果如下:
root@ubuntu:/# cat test.log
Usage: apache2 [-D name] [-d directory] [-f file]
               [-C "directive"] [-c "directive"]
               [-k start|restart|graceful|graceful-stop|stop]
               [-v] [-V] [-h] [-l] [-L] [-t] [-S] [-X]
Options:
  -D name            : define a name for use in <IfDefine name> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)
  -S                 : a synonym for -t -D DUMP_VHOSTS
  -t -D DUMP_MODULES : show all loaded modules
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  -X                 : debug mode (only one worker, do not detach)

论坛徽章:
0
6 [报告]
发表于 2010-08-31 10:52 |只看该作者
ndate=`date -d yesterday +%Y%m%d"`  多了个双引号

论坛徽章:
0
7 [报告]
发表于 2010-08-31 10:53 |只看该作者
回复 5# ghostvic


    当命令执行了?
   这样试试
   grep “$name” ’/var/log/apache2/access.log‘  > /tmp/apaLog/"$ndate".log

论坛徽章:
0
8 [报告]
发表于 2010-08-31 11:09 |只看该作者
回复 6# mercuyr


    我靠...
应该是这个问题了...

想说:“瞎了我的狗眼了”....


谢谢各位了

论坛徽章:
0
9 [报告]
发表于 2010-08-31 11:11 |只看该作者
grep $name /var/log/apache2/access.log  > /tmp/apaLog/"$ndate".log  2>/test

你这样改

看看把这句话执行以后得到的错误是什么

cat /test
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP