Log collection and periodic archiving are crucial components of automated security operations and infrastructure observability. In a multi-tier enterprise architecture, web servers continuously generate access and error logs that must be routinely copied to central storage nodes for auditing and analysis.
Jenkins provides native cron-style scheduling capabilities via Build Periodically triggers, allowing infrastructure engineers to automate recurring operational jobs without manual intervention.
This task implements:
*/12 * * * *).stapp01).scp) commands to transfer Apache logs (access_log and error_log) from /var/log/httpd/ on stapp01 to /usr/src/security/ on the Storage Server (ststor01).graph TD
subgraph CronScheduler ["Jenkins Controller (Cron)"]
Trigger["Build Periodically Trigger: */12 * * * *"]
Job["Freestyle Job: copy-logs"]
SSHPlugin["Publish Over SSH Plugin"]
end
subgraph AppServer ["App Server 1 (stapp01)"]
SSHService["SSH Daemon (User: tony)"]
ApacheLogs["Apache Logs (/var/log/httpd/)<br/>- access_log<br/>- error_log"]
SCPClient["SCP Transfer Client"]
end
subgraph StorageServer ["Storage Server (ststor01)"]
DestDir["Storage Target Directory<br/>/usr/src/security/"]
end
Trigger -->|1. Triggers Job Every 12 Mins| Job
Job -->|2. Invoke Remote Step| SSHPlugin
SSHPlugin -->|3. Connect via SSH| SSHService
SSHService -->|4. Read Log Files| ApacheLogs
ApacheLogs -->|5. Execute SCP Command| SCPClient
SCPClient -->|6. Transfer Files over SSH| DestDir
Jenkins uses a standard 5-field cron syntax (MINUTE HOUR DOM MONTH DOW) with enhanced syntax helpers:
*/12 * * * *: Evaluates to “execute every 12 minutes of every hour, every day of the month, every month, every day of the week”.The Publish Over SSH plugin enables Jenkins to interact with remote servers without installing dedicated Jenkins build agents:
8080admin / Adm!n321stapp01tonyststor01natashastapp01: /var/log/httpd/access_log, /var/log/httpd/error_logststor01: /usr/src/security/copy-logs*/12 * * * *)Publish Over SSHscp -o StrictHostKeyChecking=no /var/log/httpd/access_log /var/log/httpd/error_log natasha@ststor01:/usr/src/security/
stapp01)Before configuring the Jenkins job, establish non-interactive passwordless SSH authentication from stapp01 to ststor01 so that the automated scp command can execute without password prompts:
stapp01) via SSH:
ssh tony@stapp01
# Enter password for tony (e.g. Ir0nMan)
tony (if not already generated):
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
ststor01 (natasha user):
ssh-copy-id natasha@ststor01
# Enter password for natasha (e.g. Am3r!ca)
# Test passwordless SSH connectivity
ssh -o StrictHostKeyChecking=no natasha@ststor01 "mkdir -p /usr/src/security/"
# Test manual SCP transfer from stapp01 to ststor01
scp -o StrictHostKeyChecking=no /var/log/httpd/access_log /var/log/httpd/error_log natasha@ststor01:/usr/src/security/
adminAdm!n321
Upon signing in, verify access to the Jenkins welcome landing page:

copy-logs Freestyle Projectcopy-logs as the item name.
*/12 * * * *

Publish Over SSH.

admin.
stapp01stapp01stapp01tonytony’s password.
copy-logs job configuration page (/job/copy-logs/configure).stapp01 from the SSH Server Name dropdown.scp -o StrictHostKeyChecking=no /var/log/httpd/access_log /var/log/httpd/error_log natasha@ststor01:/usr/src/security/

copy-logs project page, click Build Now to trigger an immediate test build.#12 and #13 will execute and complete successfully (marked with green checkmark icons):

The copy-logs job is now fully scheduled to run every 12 minutes and successfully transfers the Apache logs!