我有几个专用服务器,我需要每天运行两次iptables -F 还要每天清理一次dev / md1分区。
我每天都在手动完成这一切。
我如何设置一个cron作业来执行此操作?
iptables -F和我运行的另一个命令 cp / dev / null /home/codes/a_codes/php/var/log/php-fpm.log
root@brusa-9:~# crontab -e
no crontab for root - using an empty one
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/vim.basic
4. /usr/bin/vim.tiny
Choose 1-4 [2]:
答案 0 :(得分:0)
您可以在/etc/cron.d
中创建一个新文件(根据需要为其命名,您可以免费使用)。此文件必须包含以下行:
0 */12 * * * <command to execute twice a day>
每行的开头有五个桶。这些意思是:
<Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week>
因此,在上面的示例中,您在第0分钟和每12个小时(因此每天两次)运行该任务。如果你想让它每天执行一次,例如13:20,那就是:
20 13 * * * <task to run every day at 13:20>
希望这有帮助!