Solved

Unix Scripting: How do I code the following

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 90
Generic progress indicator 6 117
move a line in eclipse 3 103
EvenOdd challenge 10 108
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…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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