My experience is that these kinds of questions are cheesy... It's a word game rather than than a technical problem.
If you were given a "hint" (which would be useful if you provided--rather than hint at in your question), and the hint involves a cron command... Well, I hate to break it to your professor, but any cron-related command that adjusts one (or more) cron jobs will implicitly update a "config file" at some point. The cron job table (which is saved to disk) must be updated whenever the system's (or a particular user's) cron jobs are updated.
If the goal is to avoid directly
modifying a file (as in typing in an editor-like environment), then you can take advantage of the fact that the crontab
command can read from standard input to replace an existing crontab file (and thereby avoid the editor-like interface "crontab -e" provides).
echo '0 5 * * * /usr/local/bin/dailycron.bash' | crontab -
The above replaces
the entire crontab entry for the user it is run as (see man crontab
So, if your professor is the "extra credit" type, then she's probably looking for a solution that retains any prior cron jobs. In that case, you would probably need to do something like:
echo -e "$(crontab -l)\n0 5 \* \* \* /usr/local/bin/dailycron.bash" | crontab -
The above command would add a cron job to execute /usr/local/bin/dailycron.bash everyday at 5:00 AM.
Note: The above command will work even if the user has no cron jobs configured. If the user has no crontab, you'll see a "no crontab for user username
" when the command is run. That message is printed to standard error. The command above ignores standard error and appends the job entry to standard output (which in this case would be empty)--giving a crontab with a single job fed to "crontab -".
Double-Note: Pay close attention to the quoting used in the two example commands. The single quotes and double quotes were chosen with purpose
It's up to you to know what command will generate the email or cause logwatch to do what you need and substitute that command in the cron job specification (and to use the right time). But the above approach would seem to avoid editing any "config file" in every way possible for such a problem. Though, it's ultimately up to your professor whether this "counts" as editing a file.