ARTIFACTORY: Why is Log rotation not working as intended?

ARTIFACTORY: Why is Log rotation not working as intended?

AuthorFullName__c
Vishal Suvarna
articleNumber
000006207
ft:sourceType
Salesforce
FirstPublishedDate
2024-10-21T11:27:50Z
lastModifiedDate
2024-10-21
VersionNumber
2
Introduction:

When the log rotation is configured in the Artifactory end and it is not functioning as intended, if we are not encountering any error messages from the application end, we may need to check the cron logs from the server where Artifactory is hosted. This article elaborates on one such example.


Symptom:


During log rotation, if the specified log file is not rotated, we will see the following error in the cron-related system logs.

Jul 22 07:55:01 ip-xx-xxx-x-xxx CROND[2975]: (artifactory) CMD (/opt/jfrog/artifactory/app/third-party/logrotate/logrotate /opt/jfrog/artifactory/var/etc/logrotate/logrotate.conf --state /opt/jfrog/artifactory/var/etc/logrotate/logrotate-state)
Jul 22 07:55:01 ip-xx-xxx-x-xxx CROND[2975]: (CRON) ERROR chdir failed (/home/artifactory): No such file or directory

To view the cron related logs,

1. For systemd based systems:
A. To view cron logs specifically run this:
sudo journalctl -u cron
B. On some systems, the service might be named crond instead of cron, so you might need:
sudo journalctl -u crond


2. System log file:
Some systems still log cron jobs to a file in /var/log/. Check /var/log/syslog or /var/log/messages:
sudo grep CRON /var/log/syslog
OR
sudo grep CRON /var/log/messages


3. For older systems or systems using syslog:
A. Syslog File:
On older systems that use traditional syslog, cron logs might be in following location /var/log/syslog (Debian-based) or /var/log/messages (Red Hat-based):
sudo grep CRON /var/log/syslog
OR
sudo grep CRON /var/log/messages
B. Dedicated Cron Log File:
    On some systems, cron logs are directed to a specific file like /var/log/cron:
    sudo cat /var/log/cron



Resolution 

1. Create a directory called “artifactory” under /home.
For example: the final path would be /home/artifactory

2. Provide the required permissions by executing the below command:

chown -R artifactory:artifactory /home/artifactory