This topic created in 4280 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
 |
|
1
billlee Aug 30, 2014
环境变量的问题,试试用 iptables-save 的完整路径
|
 |
|
2
lnkisi Aug 30, 2014
是不是PATH的问题,iptables-save用全路径试试吧。
|
 |
|
3
lonely520224 Aug 30, 2014
我也失败过,后来是把命令写到脚本里面,然后crond里面写运行脚本解决的 等楼下解释
|
 |
|
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@~]#
|
 |
|
6
shakespark Aug 30, 2014
*/1 * * * * /sbin/iptables-save > /etc/sysconfig/iptables
or
*/1 * * * * /etc/init.d/iptables save
|
 |
|
7
sansan2014 Aug 30, 2014
谢谢各位,已经解决,是路径问题,用/sbin/iptables-save解决
|