Skip to content

Commit

Permalink
Append logrotate to existing crontab in agents (#2377)
Browse files Browse the repository at this point in the history
Also handle duplicate entries
  • Loading branch information
ramanan-ravi authored Nov 23, 2024
1 parent 466a676 commit 2ae5148
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 2ae5148

Please sign in to comment.