Solved

Unix Scripting: How do I code the following

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
canBalance challenge 34 111
scoreUp challenge 14 74
how to split multiple lines delimiter : 8 133
Making an alias 7 121
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

751 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