LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-19-2012, 04:04 PM   #1
BMan8577
Member
 
Registered: Apr 2011
Posts: 73

Rep: Reputation: 0
Question I wasn't sure where to go but here is my problem...


This is for my Linux class, and the instructor that I have encourages us to use problem solving skills no matter how we do it. She encouraged us to use forums such as this one for assistance. Anyways, here is the problem I am trying to figure out. In one of the Labs we have to "Configure logwatch to email reports to the root user once per hour without configuring any files. The hint is to use a specific cron command to do this. Now my problem is that in order to use a cron command, you have to edit the /etc/cron.hourly file. Because I have looked through the man files and came up with nothing that is related to what I am asked to do. I need some assistance, hints, or help of any kind. Thanks. This is the only question I need to get a high score. I will give the credit to you to my instructor for this problem...lol. The only thing I can think of is to use an echo command into the file, but that would still be considered editing a file. Any hints or assistance that can help me to better understand what I am missing? Thank you so much guys...I love this forum and plan to use it in the future when I obtain a career.
 
Old 02-19-2012, 04:26 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Well everything in linux is a file .. but maybe you could get away with 'crontab -e' as root
 
Old 02-19-2012, 04:29 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,889

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
Browse the web and look for a crontab tutorial that will show you how to schedule the timing of execution. Cron can execute every minute, hour, day, week, or month, as you choose. You configure a crontab to run cron; you don't edit config files.

Last edited by bigrigdriver; 02-19-2012 at 10:18 PM.
 
Old 02-19-2012, 06:21 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
I think what your instructor wants is for you to edit cron only (ok, that's a cfg file of sorts), but not the logwatch cfg.
I'm sure you're allowed to ask him for clarification; I would(!)

This may help
http://www.adminschoice.com/crontab-quick-reference
 
Old 02-19-2012, 11:30 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
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).

For instance:
Code:
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:
Code:
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 -".

EDIT
Double-Note: Pay close attention to the quoting used in the two example commands. The single quotes and double quotes were chosen with purpose
/EDIT

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.

Last edited by Dark_Helmet; 02-19-2012 at 11:34 PM.
 
1 members found this post helpful.
Old 02-19-2012, 11:38 PM   #6
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 36
^^I think dark helmet has put it in more precise manner.
Everything in linux is file so your teacher just wants a different way of editing the file rather than editing a file in known way.


P.S.
Do share your teacher's comments after you done with your homework
 
Old 02-25-2012, 01:44 PM   #7
BMan8577
Member
 
Registered: Apr 2011
Posts: 73

Original Poster
Rep: Reputation: 0
The command to this answer was "mv /etc/cron.daily /etc/cron.hourly". I tell you what you guys have helped me so much. The first two Linux System Admin I & II were not bad dealing with the basics of navigating file system documents and learning about the Linux/Unix system (Sys Admin I - got an A) and Configuring Hardware and Virtualizing Linux (Sys Admin II - got a B), but this System Admin III dealing with Security Administration is a bit difficult. These classes are required for my degree in Operating Systems/Networking. But I give credit to you guys and thank you so much for everything. I think this class I will end up with at least a C I hope...lol. But for someone who didn't know a thing about Linux or Unix this a been a cool journey for me but difficult lol.
 
Old 02-25-2012, 01:47 PM   #8
BMan8577
Member
 
Registered: Apr 2011
Posts: 73

Original Poster
Rep: Reputation: 0
I gave you guys credit for helping me to my instructor and she said whatever helps to learn this material is a good thing...lol. Thanks and thanks to Linux for this great forum!
 
Old 02-25-2012, 01:50 PM   #9
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Well, I hope it turns out well for you.

But I have to say:
Quote:
Originally Posted by BMan8577
The hint is to use a specific cron command to do this.
and the solution was:
Quote:
Originally Posted by BMan8577
mv /etc/cron.daily /etc/cron.hourly
The mv command is most certainly not a cron command That solution is also distribution dependent. Your professor may mark you with a "C," but if I were grading your professor and the professor said to use a "cron command," then the professor would get an "F."
 
1 members found this post helpful.
Old 02-25-2012, 02:52 PM   #10
BMan8577
Member
 
Registered: Apr 2011
Posts: 73

Original Poster
Rep: Reputation: 0
Well sometimes the instructor finds labs or questions wrong that Red Hat think is right. Sometimes a question or lab is confusingly worded and she gives us what they really are looking for. Which the instructor will email us with the correct lab question or test question which happens somewhat often, or Red Hat grades some questions wrong when a student selects the correct answer which I have found a few times throughout the courses. So it can go either way. I do agree that she shouldn't have said it's a cron command unless I mistakenly got the question mixed up. Overall she is a good instructor and she does know what she is talking about...lol. But I would say if it were any other instructor they wouldn't be kind enough to reset questions, test questions, or lab tests. She wants us to more or less understand the commands, what they are used for, what switches can be used, etc. But thanks for the reply .
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware acts as if binary wasn't even there... :-| Alexvader Slackware 4 12-07-2009 05:30 PM
wasn't asked for root password during install... what to do ? willy_9 SUSE / openSUSE 13 10-18-2009 02:32 AM
Ok.. my problem wasn't solved.... but at least I got my important files back... Ntvu Linux - Newbie 6 06-21-2008 07:17 PM
New Linux distro I wasn't aware of? Hal General 3 12-08-2003 03:15 PM
Why wasn't amixer installed with Alsa ashtar Linux - General 1 04-12-2002 01:32 PM


All times are GMT -5. The time now is 06:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration