Solved

Unix Scripting: How do I code the following

Posted on 2003-11-19
5
923 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 55
sum13 challenge 24 132
matchUp  challenge 6 76
java ^ examples 8 69
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

685 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