Solved

Unix Scripting: How do I code the following

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

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 11

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now