Cron Expression: Every Day at 6:00 PM (0 18 * * *)
Need to generate a cron expression?
Use CronOS to generate any cron expression you wish with natural language. Simply describe what you need, and we'll create the perfect cron expression for you. It's completely free!
Cron Expression: Every Day at 6:00 PM (0 18 * * *)
The cron expression 0 18 * * * executes a task every day at 6:00 PM (18:00), making it ideal for end-of-business-day operations, daily summaries, and tasks that should run when the workday ends.
Expression Breakdown
0 18 * * *
│ │ │ │ │
│ │ │ │ └─── Day of week: * (every day)
│ │ │ └───── Month: * (every month)
│ │ └─────── Day of month: * (every day)
│ └────────── Hour: 18 (at hour 18, 6:00 PM)
└───────────── Minute: 0 (at minute 0)
Field Values
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 |
| Hour | 18 | At hour 18 (6:00 PM) |
| Day of Month | * | Every day (1-31) |
| Month | * | Every month (1-12) |
| Day of Week | * | Every day of week (0-7) |
Execution Time
This expression runs once per day at:
- 18:00 (6:00 PM)
Common Use Cases
1. End-of-Day Reports
0 18 * * * /usr/bin/python3 /scripts/generate-end-of-day-report.py
Generate and send end-of-business-day reports or summaries.
2. Daily Summaries
0 18 * * * /usr/bin/python3 /scripts/create-daily-summary.py
Create daily summaries, statistics, or analytics for the business day.
3. Data Backup
0 18 * * * /usr/local/bin/end-of-day-backup.sh
Create backups or snapshots at the end of the business day.
4. Cache Refresh
0 18 * * * /usr/bin/python3 /scripts/refresh-cache.py
Refresh cached data or computed values for the next day.
Example Implementations
End-of-Day Report Script
# generate-end-of-day-report.py
import json
from datetime import datetime
import sqlite3
def generate_end_of_day_report():
conn = sqlite3.connect('/var/data/app.db')
cursor = conn.cursor()
# Get daily metrics
cursor.execute('''
SELECT
COUNT(*) as total_requests,
AVG(response_time) as avg_response_time,
COUNT(CASE WHEN status_code >= 400 THEN 1 END) as errors,
COUNT(DISTINCT user_id) as unique_users
FROM requests
WHERE DATE(timestamp) = DATE('now')
''')
metrics = cursor.fetchone()
report = {
'date': datetime.now().strftime('%Y-%m-%d'),
'time': 'end_of_day',
'metrics': {
'total_requests': metrics[0],
'avg_response_time': round(metrics[1], 2) if metrics[1] else 0,
'errors': metrics[2],
'unique_users': metrics[3],
'error_rate': round((metrics[2] / metrics[0] * 100), 2) if metrics[0] > 0 else 0
}
}
# Save report
with open(f'/var/reports/end_of_day_{datetime.now().strftime("%Y%m%d")}.json', 'w') as f:
json.dump(report, f, indent=2)
print(f"{datetime.now()}: End-of-day report generated")
conn.close()
if __name__ == '__main__':
generate_end_of_day_report()
Daily Summary Script
# create-daily-summary.py
from datetime import datetime
import sqlite3
def create_daily_summary():
conn = sqlite3.connect('/var/data/app.db')
cursor = conn.cursor()
# Aggregate daily data
cursor.execute('''
INSERT INTO daily_summaries (date, total_transactions, revenue, created_at)
SELECT
DATE('now'),
COUNT(*),
SUM(amount),
?
FROM transactions
WHERE DATE(created_at) = DATE('now')
''', (datetime.now(),))
conn.commit()
conn.close()
print(f"{datetime.now()}: Daily summary created")
if __name__ == '__main__':
create_daily_summary()
Best Practices
- Timing: 6 PM aligns with typical business day end
- Error Handling: Implement comprehensive error handling and logging
- Locking: Use file locks to prevent concurrent execution
- Monitoring: Set up alerts for failed jobs
- Performance: Optimize tasks to complete efficiently
When to Use
✅ Good for:
- End-of-day reports
- Daily summaries
- End-of-day backups
- Cache refresh
- Business day wrap-up tasks
❌ Avoid for:
- Real-time critical operations
- Very long-running processes
Related Patterns
| Pattern | Expression | Description |
|---|---|---|
| Daily at noon | 0 12 * * * | Midday |
| Daily at 6 PM | 0 18 * * * | End of business day |
| Daily at 11 PM | 0 23 * * * | Late evening |
Conclusion
The 0 18 * * * expression is perfect for end-of-business-day operations. It's commonly used for reports, summaries, and tasks that should run when the workday ends, providing closure on daily operations and preparing for the next day.
Need to generate a cron expression?
Use CronOS to generate any cron expression you wish with natural language. Simply describe what you need, and we'll create the perfect cron expression for you. It's completely free!