linux shell 0403-011,shell脚本出现 test:0403-004 Specify a paramater with this command

下面是小弟从网上找的一段SHELL代码,用来解决WEBLOGIC日志不能自动分割的问题,可是SHELL脚本有误,运行的时候报

start.sh【7】:test:0403-004 Specify a paramater with this command 请各位大虾帮帮忙

You can use the following script to rotate, by size, the nohup.out file. The script takes a size parameter to check against the size of the nohup.out file. If the file is greater than that specified size, it will copy the file to a logs directory appending the date and time to it and will empty the existing nohup.out and continue the logging.

The script should be started as a daemon process so it is continually running in the background. It should be run from where you store nohup.out - usually the domain directory, and make sure that there is a logs directory underneath the directory where you have nohup.out.

The script will run continuously until killed by user.

-----------

#!/bin/bash

counter=1

file=nohup.out

while [ "$counter" != "0" ]

do

size=`ls -la nohup.out | awk '{print $5}'`

if [ $size -gt $1 ]

then

date=`date +%m%d%y-%H%M%S`

cp "$file" log/"$file.$date"

cat /dev/null > "$file"

fi

done

-----------

Thanks and please let me know if it works at your end.

|

很明显是需要一个参数么,在运行这个脚本时你要指定"$1",是个整数,就是if [ $size -gt $1 ]里面的,他就是用来分割文件大小的界限。

|

那你应该看下,那个看那个存放拷贝后的目录是不是存在,就是log/这个目录,或者你可以重新指定一个目录,比如指定到cp "$file" /var/log/[/color]"$file.$date",运行完之后查看/var/log/是不是生成了那个拷贝后的文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值