how to run a logrotate hourly

后端 未结 2 1723
野趣味
野趣味 2021-01-24 03:52

I created a program.conf that logrotate my logs hourly in an EC2 instance. the logrotate works well when i force it command (by sudo logrotate program.conf --verbose --force<

2条回答
  •  深忆病人
    2021-01-24 04:13

    You will need to add the job in your crontab

    crontab -e
    

    And then add a job that runs every hour 14 minutes past,

    14 * * * * /usr/sbin/logrotate /home/sammy/logrotate.conf --state /home/sammy/logrotate-state
    

    Taken from : https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-16-04

    Also additionally check if the crontab is actually running by doing

    service crontab status
    

    if it is stopped you can start it by doing

    service crontab start
    

提交回复
热议问题