Linux CLI - Cron and SchedulingHow would you write a crontab entry to run a backup script at 11:59 PM on the last day of every month?A59 23 31 * * /path/backup.shB59 23 * * * /path/backup.shC59 23 * * 31 /path/backup.shD59 23 28-31 * * [ $(date -d tomorrow +\%d) = 01 ] && /path/backup.shCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand last day of month challengeCrontab cannot directly specify last day; use days 28-31 and test if tomorrow is day 1.Step 2: Analyze 59 23 28-31 * * [ $(date -d tomorrow +\%d) = 01 ] && /path/backup.shRuns at 23:59 on days 28-31 and uses shell test to check if next day is 1, meaning last day.Final Answer:59 23 28-31 * * [ $(date -d tomorrow +\%d) = 01 ] && /path/backup.sh -> Option DQuick Check:Use day range + shell test for last day detection [OK]Quick Trick: Use day 28-31 plus shell test for last day [OK]Common Mistakes:Using day 31 only (fails for months with fewer days)Misusing day of week fieldIgnoring shell test necessity
Master "Cron and Scheduling" in Linux CLI9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Linux CLI Quizzes Cron and Scheduling - Common cron expressions - Quiz 5medium Cron and Scheduling - Cron log monitoring - Quiz 13medium Cron and Scheduling - at command for one-time jobs - Quiz 2easy Environment and Configuration - History command and search - Quiz 10hard Package Management - Installing, updating, removing packages - Quiz 7medium Package Management - Building from source basics - Quiz 4medium SSH and Remote Access - Why SSH enables secure remote management - Quiz 2easy SSH and Remote Access - Why SSH enables secure remote management - Quiz 3easy System Administration - System resource monitoring (free, uptime, vmstat) - Quiz 10hard System Administration - journalctl for systemd logs - Quiz 10hard