Skip to content

Commit

Permalink
Append logrotate to existing crontab in agents
Browse files Browse the repository at this point in the history
Also handle duplicate entries
  • Loading branch information
ramanan-ravi committed Nov 22, 2024
1 parent 44176d5 commit 1eb1574
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion deepfence_agent/start_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ configure_cron() {
#doesnt work smoothly inside docker!
service cron start
chmod 600 /etc/logrotate.d/fenced_logrotate.conf
(echo "*/5 * * * * /usr/sbin/logrotate /etc/logrotate.d/fenced_logrotate.conf") | crontab -
MARK="/etc/logrotate.d/fenced_logrotate.conf"
crontab_output=$(crontab -l)
if [ $(echo "$crontab_output" | grep -ic "$MARK") -eq 0 ]
then
{ crontab -l; echo "*/5 * * * * /usr/sbin/logrotate /etc/logrotate.d/fenced_logrotate.conf"; } | crontab -
fi
}

launch_deepfenced() {
Expand Down

0 comments on commit 1eb1574

Please sign in to comment.