linux crontab 定时使用方法
可参考:
https://www.jianshu.com/p/3ffc228df68c
一、只有在ROOT用户下可以执行
1.文件目录
00 07 * * * root cd /home/op/saiyan_game_center && venv/bin/python statistics_data/odps_calc_game_center_new_day_alive.py >/tmp/goldfinger.cron 2>&1 00 08 * * * root cd /home/op/saiyan_game_center && venv/bin/python statistics_data/odps_calc_game_center_new_add.py >/tmp/goldfinger.cron 2>&1 30 08 * * * root cd /home/op/saiyan_game_center && venv/bin/python statistics_data/odps_calc_game_center_box_keep.py >/tmp/goldfinger.cron 2>&1 30 06 * * * root cd /home/op/saiyan_game_center && venv/bin/python statistics_data/odps_calc_roi.py >/tmp/odps_calc_roi.cron 2>&1
2.软链接到 /etc/cron.d
3.重启
sudo service cron reload
二、任何用户
# 每5分钟执行一次 */5 * * * * cd /home/op/game_extra_app && venv/bin/python bin/log_monitor.py >/tmp/extra_log_monitor.cron 2>&1 # 每天零点执行 00 00 * * * cd /home/op/game_app_rtl && venv/bin/python bin/rotate_logs.py >/tmp/game_app_rtl.cron 2>&1 # 9:31 17:31执行 31 09,17 * * * cd /home/op && game_extra_app/venv/bin/python statistics_data/commons/odps_calc_all_app.py >/tmp/all_app.cron 2>&1 # 17:20执行 20 17 * * * cd /home/op && game_extra_app/venv/bin/python statistics_data/huanle_box/odps_calc_day_ltv.py >/tmp/day_ltv.cron 2>&1 # 每小时执行一次 0 */1 * * * cd /data/gameserver && venv/bin/python bin/online_user_data.py >/tmp/online_user_data.cron 2>&1 # 每3小时执行一次 1 */3 * * * cd /app/aiphoto/ai_photo && python aiphoto/imagebackend/order_cache.py > /tmp/order_cache.txt # 每4个小时执行一次 追加写入文件 1 */4 * * * /app/aiphoto/venv/bin/python /app/aiphoto/ai_photo/aiphoto/imagebackend/order_merge.py >> /tmp/order_merge.txt # 每月凌晨2点执行 00 2 10 * * /app/aiphoto/venv/bin/python /app/aiphoto/ai_photo/aiphoto/imagebackend/order_export.py "" "" > /tmp/order_export.txt #每月1、10、22日的4 : 45重启smb 45 4 1,10,22 * * /etc/init.d/smb restart