Hi, thanks for reporting your findings. However the first of these is not an issue, instead you have used an incorrect format for your crontab file.
Individual users crontab files (ie. those edited via crontab -e, or sudo crontab -e for root's), DO NOT contain a field for the user. (since the user is already known from the ownership of the crontab)
/etc/crontab and the files in /etc/cron.d and /etc/cron.{hourly, daily, weekly, monthly} DO contain a field for the user.
so your entry:
Code:
* * * * * root /bin/date > /var/log/date.txt
is only valid for either /etc/crontab, or within a file in one of the cron directories. I'm surmising however that you had that in root's crontab, ie. sudo crontab -e.
If you put that entry in a users crontab, the piece root /bin/date > /var/log/date.txt gets treated as the command to run, and since there is no executable on your system named root, it fails.
For your variant:
Code:
* * * * * root cd / ; /bin/date > /var/log/date.txt
root cd / ; /bin/date > /var/log/date.txt is the command that gets run ... the first statement (root cd /) will fail, but the second /bin/date > /var/log/date.txt will succeed, and the exit status of the last command determines the overall job success/failure as far as cron is concerned.
Regarding the second issue of file names, yes, the filename convention required for files in the /etc/cron* directories is documented in man cron, excerpt here:
Code:
Files must conform to the same naming convention as used by run-
parts(8): they must consist solely of upper- and lower-case letters,
digits, underscores, and hyphens.
Bookmarks