Configuring Cron Job on Nautilus Storage Server
Objective
This document outlines the procedure for installing and configuring a cron job on the Nautilus Storage Server (ststor01) in the Stratos Datacenter. The system administration team requires the following configuration:
- Install the cronie package and start the crond service
- Add a cron job to the root user's crontab that executes
/usr/bin/touch test_passeddaily at 21:30
Environment Details
- Server: ststor01 (Nautilus Storage Server)
- Access User: natasha
- Access Password: Bl@kW
- Sudo Privileges: Required
Implementation Methods
Method 1: One-Line Command Execution
Execute the following command from the jump host to perform all required actions:
echo 'Bl@kW' | ssh natasha@ststor01 "sudo -S bash -c 'yum install -y cronie && systemctl start crond && systemctl enable crond && (crontab -l 2>/dev/null; echo \"30 21 * * * /usr/bin/touch test_passed\") | crontab - && crontab -l'"
This command performs the following actions:
- Installs the cronie package
- Starts the crond service
- Enables crond to start on boot
- Adds the cron job to root's crontab
- Displays the current crontab for verification
Method 2: Heredoc Method
For a comprehensive output with detailed verification, use the heredoc approach:
ssh natasha@ststor01 << 'EOF'
echo 'Bl@kW' | sudo -S bash -c '
echo "Installing cronie package"
yum install -y cronie
echo "Starting crond service"
systemctl start crond
systemctl enable crond
echo "Service Status"
systemctl status crond | grep -E "Active|Loaded"
echo "Adding cron job to root crontab"
(crontab -l 2>/dev/null; echo "30 21 * * * /usr/bin/touch test_passed") | crontab -
echo "Current Crontab"
crontab -l
echo "Verification"
crontab -l | grep -q "30 21 \* \* \* /usr/bin/touch test_passed" && echo "Cron job added successfully" || echo "Cron job not found"
'
EOF
Method 3: Interactive Session
For manual execution, connect to the server and perform the following commands:
# Connect to storage server
ssh natasha@ststor01
# Enter password: Bl@kW
# Switch to root
sudo su -
# Enter password: Bl@kW
# Install cronie
yum install -y cronie
# Start and enable crond service
systemctl start crond
systemctl enable crond
# Verify service status
systemctl status crond
# Add cron job to root's crontab
(crontab -l 2>/dev/null; echo "30 21 * * * /usr/bin/touch test_passed") | crontab -
# Verify the cron job
crontab -l
# Exit
exit
exit
Command Breakdown
Installation and Service Commands
-
yum install -y cronie: Installs the cronie package non-interactively -
systemctl start crond: Starts the cron daemon service -
systemctl enable crond: Configures crond to start automatically at boot
Cron Job Addition
The command structure for adding the cron job is:
(crontab -l 2>/dev/null; echo "30 21 * * * /usr/bin/touch test_passed") | crontab -
This command:
-
crontab -l 2>/dev/null: Lists existing crontab entries, suppressing errors if none exist -
echo "30 21 * * * /usr/bin/touch test_passed": Defines the new cron job -
| crontab -: Pipes the combined output to replace the crontab
Cron Syntax Explained
The cron expression 30 21 * * * consists of:
| Position | Value | Meaning |
|---|---|---|
| Minute | 30 | At 30 minutes past the hour |
| Hour | 21 | At 21:00 (9:30 PM) |
| Day of Month | * | Every day of the month |
| Month | * | Every month |
| Day of Week | * | Every day of the week |
The command /usr/bin/touch test_passed updates the timestamp of the file test_passed in the current working directory (root's home directory by default).
Verification Procedures
After configuration, verify the setup using these commands:
# Verify cronie installation
rpm -qa | grep cronie
# Verify crond service status
systemctl status crond
# Verify crond is enabled on boot
systemctl is-enabled crond
# View root's crontab
crontab -l
# Verify the specific cron job exists
crontab -l | grep "30 21"
# Check cron logs for activity
tail -f /var/log/cron
# Check system logs for cron activity
journalctl -u crond | tail -20
Expected Output
Upon successful execution, the system should display:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package cronie-1.5.2-4.el8.x86_64 already installed and latest version
Nothing to do
Created symlink from /etc/systemd/system/multi-user.target.wants/crond.service to /usr/lib/systemd/system/crond.service.
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2026-07-19 10:00:00 UTC; 1min ago
Main PID: 1234 (crond)
Tasks: 1 (limit: 512)
Memory: 1.2M
CGroup: /system.slice/crond.service
└─1234 /usr/sbin/crond -n
30 21 * * * /usr/bin/touch test_passed
Alternative Approaches
Method 1: Direct Crontab Editing
# Open root's crontab in editor
crontab -e
# Add this line:
30 21 * * * /usr/bin/touch test_passed
# Save and exit
Method 2: Using /etc/crontab
# Add to system-wide crontab
echo "30 21 * * * root /usr/bin/touch test_passed" >> /etc/crontab
Method 3: Using Cron Directory
# Create a file in cron.d directory
echo "30 21 * * * root /usr/bin/touch test_passed" > /etc/cron.d/test_passed
Method 4: Preserving Existing Crontab
# Backup existing crontab, add new job, restore
crontab -l > /tmp/crontab_backup 2>/dev/null
echo "30 21 * * * /usr/bin/touch test_passed" >> /tmp/crontab_backup
crontab /tmp/crontab_backup
rm /tmp/crontab_backup
Troubleshooting
Issue 1: Package Not Found
# Search for available cron packages
yum search cronie
# Try alternative package names
yum install -y vixie-cron crontabs
Issue 2: Service Start Failure
# Check service logs
journalctl -u crond -n 50
# Reload systemd
systemctl daemon-reload
# Check service unit file
systemctl cat crond
Issue 3: Crontab Command Not Found
# Install crontabs package
yum install -y crontabs
Issue 4: Cron Job Not Executing
# Verify crond is running
systemctl status crond
# Check logs for errors
tail -f /var/log/cron
# Verify command path
which touch
# Use absolute path in cron command
Issue 5: Permission Denied
# Use sudo for all operations
sudo crontab -e
# Or switch to root
sudo su -
Issue 6: File Not Created
# Use absolute path in command
echo "30 21 * * * /usr/bin/touch /root/test_passed" | crontab -
# Verify working directory
crontab -l | grep touch
Cron Locations Reference
| Location | Purpose |
|---|---|
/etc/crontab |
System-wide crontab file |
/etc/cron.d/ |
Directory for system crontab files |
/etc/cron.hourly/ |
Scripts executed every hour |
/etc/cron.daily/ |
Scripts executed daily |
/etc/cron.weekly/ |
Scripts executed weekly |
/etc/cron.monthly/ |
Scripts executed monthly |
/var/spool/cron/ |
User-specific crontab files |
Automated Script
For repeatable deployments, save this as setup_cron.sh:
#!/bin/bash
echo "Configuring Cron Job on Storage Server"
ssh natasha@ststor01 << 'EOF'
echo 'Bl@kW' | sudo -S bash -c '
echo "Installing cronie"
yum install -y cronie
echo "Starting and enabling crond"
systemctl start crond
systemctl enable crond
echo "Service Status"
systemctl status crond | grep -E "Active|Loaded"
echo "Adding cron job"
(crontab -l 2>/dev/null; echo "30 21 * * * /usr/bin/touch test_passed") | crontab -
echo "Current Crontab"
crontab -l
echo "Verification"
crontab -l | grep -q "30 21 \* \* \* /usr/bin/touch test_passed" && echo "Cron job added successfully" || echo "Cron job not found"
'
EOF
Make the script executable and run:
chmod +x setup_cron.sh
./setup_cron.sh
Summary
The cron job has been successfully configured on the Nautilus Storage Server (ststor01) with the following specifications:
- Package: cronie installed
- Service: crond running and enabled on boot
-
Cron Job:
30 21 * * * /usr/bin/touch test_passed - Schedule: Every day at 21:30 (9:30 PM)
-
Command: Updates timestamp on
test_passedfile - User: Root user's crontab
- Status: Verified and active
The configuration has been completed successfully, and the cron job will execute daily at the specified time. The system logs can be monitored to confirm the execution of the cron job.
Top comments (0)