crond 创建 iptables-save 失败 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
sansan2014

crond 创建 iptables-save 失败

  •  
  •   sansan2014 Aug 30, 2014 3173 views
    This topic created in 4259 days ago, the information mentioned may be changed or developed.
    我想用crond创建一条每分钟执行一次iptables-save,我添加的命令如下
    */1 * * * * iptables-save > /etc/sysconfig/iptables
    当自动执行后,/etc/sysconfig/iptables就会变成一片空白

    如果我是在#命令下,直接执行iptables-save > /etc/sysconfig/iptables,执行的备份操作就是正常的
    请大侠指点一下,错在哪里,谢谢!
    7 replies    2014-08-30 00:46:07 +08:00
    billlee
        1
    billlee  
       Aug 30, 2014
    环境变量的问题,试试用 iptables-save 的完整路径
    lnkisi
        2
    lnkisi  
       Aug 30, 2014
    是不是PATH的问题,iptables-save用全路径试试吧。
    lonely520224
        3
    lonely520224  
       Aug 30, 2014
    我也失败过,后来是把命令写到脚本里面,然后crond里面写运行脚本解决的
    等楼下解释
    lonely520224
        4
    lonely520224  
       Aug 30, 2014
    PS,我用的是全路径,也是失败
    lnkisi
        5
    lnkisi  
       Aug 30, 2014
    完全没问题


    [root@~]# crontab -l | tail -n 1
    * * * * * /sbin/iptables-save > /tmp/iptables
    [root@~]# cat /tmp/iptables
    # Generated by iptables-save v1.4.7 on Sat Aug 30 00:34:01 2014
    *filter
    :INPUT ACCEPT [15825554:2711069853]
    :FORWARD ACCEPT [1727485:459585856]
    :OUTPUT ACCEPT [19587930:3518448521]
    COMMIT
    # Completed on Sat Aug 30 00:34:01 2014
    [root@~]#
    shakespark
        6
    shakespark  
       Aug 30, 2014
    */1 * * * * /sbin/iptables-save > /etc/sysconfig/iptables

    or

    */1 * * * * /etc/init.d/iptables save
    sansan2014
        7
    sansan2014  
    OP
       Aug 30, 2014
    谢谢各位,已经解决,是路径问题,用/sbin/iptables-save解决
    About     Help     Advertise     Blog     API     FAQ     Solana     5123 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 45ms UTC 09:45 PVG 17:45 LAX 02:45 JFK 05:45
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86