/var/spool/cron与/var/spool/cron/crontabs的区别及成因咨询
Great question! Let's break down the difference between /var/spool/cron and /var/spool/cron/crontabs, and why you might encounter one or the other across different Linux distributions.
/var/spool/cron: This is the classic directory used by the original Vixie cron (the most widely adopted cron implementation). Here, each user's crontab is stored as a file named directly after the user—so you’ll see files likeroot,jane, orbobsitting right inside this directory, each containing that user’s scheduled tasks./var/spool/cron/crontabs: This path is specific tocronie, a modern fork of Vixie cron used by distros like Debian, Ubuntu, Fedora, and RHEL. Withcronie, individual user crontabs live inside thecrontabssubdirectory instead of directly under/var/spool/cron. The file naming rule stays the same (user-named files), but this extra layer helps keep cron-related files more organized and aligns with newer filesystem structure conventions.
The discrepancy boils down to which cron implementation a distro ships by default:
- Distros that prioritize sticking to the original Vixie cron (often older or more minimal distros) use
/var/spool/crondirectly. - Distros that adopted
cronie(which adds improvements like enhanced security checks and better compatibility with modern systems) opted for the/var/spool/cron/crontabsstructure.
In some cases, you might even find symlinks between these paths to maintain backward compatibility—for example, a cronie-based system might have a symlink from /var/spool/cron pointing to /var/spool/cron/crontabs, though this isn’t a universal setup.
One important note: no matter which path your system uses, the crontab command behaves identically for end users. When you run crontab -e to edit your scheduled tasks, the system automatically saves your changes to the correct directory for the installed cron implementation.
内容的提问来源于stack exchange,提问作者Sajuuk




