[CentOS] cat cron jobs crontab: SOLVED
Karl R. Balsmeier
karl at klxsystems.net
Tue Mar 13 19:25:35 UTC 2007
so to script the thing it's actually done like this, doh:
-------------snip------------
#show crontab, on a new system should be empty:
crontab -l
#put in whatever cron checks you need, one by one...
echo "*/3 * * * * /usr/lib64/nagios/plugins/check_megaraid_passive.sh >
/dev/null 2>&1" >> /var/spool/cron/root
# restart crond afterward
service crond restart
# show you results, new stuff should be there.
crontab -l
------------------snip---------------
dunno why I was trying to do this elaborate EOF thing.
-krb
Karl R. Balsmeier wrote:
> thanks, I'm running a script after kickstart install, and am looking
> to "cat" a known value into an empty cron file. Managing it or
> otherwise having to manually edit it is not the issue i'm seeking info
> on.
>
> I'm trying to avoid having to manually add all of my known cron jobs
> with crontab -e
>
> To do this, I was trying out some stuff like:
>
> *cat >> $out_file << EOF
> first line of data
> second line of data
> more data
> the end of the data
> EOF*
>
> but in a way that was safe for cron, with no modifications to the
> default manner in which cron runs, e.g. crontab -l, crontab -e later
> would not break seeking some new file.
>
> -karlski
>
>
> Matt Hyclak wrote:
>
>> On Tue, Mar 13, 2007 at 11:32:55AM -0500, Styma, Robert E (Robert)
>> enlightened us:
>>
>>
>>> The most common way I have seen ov updating crontab is the
>>> crontab command.
>>>
>>> 1. login or su to the appropriate user
>>> 2. crontab -l > /tmp/crontab.txt
>>> 3. edit /tmp/crontab.txt to your liking
>>> 4. crontab /tmp/crontab.txt
>>>
>>> This gets the right files in the right places an alerts cron
>>> of the change.
>>>
>>>
>>
>>
>> Or you could just type crontab -e and not copy tmp files around.
>>
>> This method is fine when you're not trying to automate something, so
>> is good
>> information, but less useful to the OP.
>>
>> Matt
>>
>>
>>
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
More information about the CentOS
mailing list