Solved

Unix Scripting: How do I code the following

Posted on 2003-11-19
5
940 Views
Last Modified: 2013-12-26
Hi I have the following code which perform as stated in the comments denoted by #

#New code 17/11/2003
#New Code
#Perform apachectl configtest and log result in install log and exit if result is not Syntax OK
#The PUMA webserver is at /osmf/mgmt/UCPS/puma/webserver/
#It writes output from apachectl configtest to install.log and checks that it is Syntax OK
if [[`/osmf/mgmt/UCPS/puma/webserver/bin/apachectl configtest 2>&1`|tee install.log` !='Syntax OK']]
then
  print error with apachectl configtest
  exit
fi
print apachectl configtest is ok


What I need to do is following this code is to (Note I have not done Unix scripting before)

1. Add PUMA logtidy cron entry (crontab.puma) to root crontab if not already in place

2. grep for /osmf/mgmt/UCPS/puma/webserver/logs to detect is logtidy is already installed

3. if not installed append to root crontab


Thanks for your help
0
Comment
Question by:gillagilla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 9783724
Would UCPS happen to be Union County Public School?
0
 
LVL 12

Expert Comment

by:tel2
ID: 9784824
The whole class will stay in until gillagilla answers Tintin's question...
0
 

Author Comment

by:gillagilla
ID: 9789526
UCPS is Unix NT Capacity Planning  why???
0
 

Author Comment

by:gillagilla
ID: 9789592
Are there any experts who can help here please
0
 
LVL 12

Accepted Solution

by:
tel2 earned 500 total points
ID: 9790257
gillagilla,

> why??
Just trying to make sure it's not a homework question.

Hard to tell exactly by your description, but start by trying this:
 
Logon as root
 
Task 1.
First check if crontab.puma root cron job is already in place, like this:
  crontab -l | grep puma     # for example.  If no output, then not in place
OR
  crontab -l         # and manually check entries to see if it's already in place
If not in place, go:
  crontab -e
to edit root's crontab (this will probably put you into the "vi" editor).
Logically you can add your entry anywhere, but if you want to append the crontab, go:
  G     (to 'G'o to last line)
  o      (to 'o'pen a new after current line)
and add your entry.  Format is:
  min(s) hour(s) day(s) month(s) weekday(s) command
Note: * = All periods, and weekdays = 0 (Sun) to 6 (Sat).
eg, if you want your job to run Mon-Fri at 2:30 pm, you could put:
  30 14 1-5 * * cd /whereever-the-script-lives; ./crontab.puma >crontab.puma.out 2>crontab.puma.err
Now save your changes and exit with:
  <Esc>wq<Enter>
or if you need to quit without saving changes:
  <Esc>q!<Enter>
 
Task 2.
Need more detail to answer this really, but probably something like:
  grep logtidy /osmf/mgmt/UCPS/puma/webserver/logs/*
The syntax is:
  grep <the-text-you're-searching-for> <the-file(s)-you're-searching>
 
Task 3.
Append what to root crontab?  How does this differ from task 1?

Any questions?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question