Cron job with privileged commands - redhat linux
Hi,
I want to create a cron job which has a few commands (to restore generic iptables with minimum level security) that need sudo privileges. The file has the following commands : ... /sbin/iptables-save > /home/user1/iptables_bkp.txt /sbin/iptables-restore > /home/user1/original_iptables.txt /sbin/service iptables save /sbin/service iptables restart ... I have scheduled this as the root's crontab. It does execute at every timeout, however the iptables_bkp.txt file is blank, and the original iptables file is not uploaded. Is there something missing that should be done to make this work ? Regards, ~Abhi |
You say "the file" has the following commands. Is it a script ? If so, you need to make sure you have chmodded it 755, and it probably won't hurt to have a shebang line at the top. Then you call the script from the crontab.
Code:
#!/bin/bash chmod 755 my_script.sh chown root:root my_script.sh |
All times are GMT -5. The time now is 08:55 AM. |