Link to home
Start Free TrialLog in
Avatar of CAVALLOSILF
CAVALLOSILF

asked on

SCRIPT IN LINUX

I to Everybody.
I need an information.
I have just a little experience in Linux.
I would like to auto some operations that are running every morning.

Es. i need to auto STOP and START of TOMCAT at 4.50 a.m with normal command /etc/init.d/tomcat stop and copy CATALINA.out in CATALINA1.OUT, and after delete CATALINA.out, and after start Tomcat with command /etc/init.d/TOMCAT start.
It's possible? I think yes.... of course.

It's possible to have some example or help?
Thanks in advance.

ASKER CERTIFIED SOLUTION
Avatar of praseedgopal
praseedgopal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CAVALLOSILF
CAVALLOSILF

ASKER

FANTASTIC !!!
Thank you very much!!
Dear praseedgopal
i have try to create exe file using

chmod +x myshell.sh but i haven't create....

i have create myshell.sh with using vi editor....

this is myshell.sh and are in /usr/local/tomcat5028/logs

#! /bin/bash
#To cp catalina.out
cp catalina.out catalina2.out


First create myshell.sh using vi editor.
There is one correction in the step

mv CATALINA.out CATALINA1.OUT

Instead of giving CATALINA.out and CATALINA1.OUT, give absolute path of both these files.
Suppose if they are in /tmp/. Give as

mv /tmp/CATALINA.out /tmp/CATALINA1.OUT

and after saving the file, from console, run the command

chmod +x myshell.sh

this will make your script(myshell.sh) an executable one. Final script will look like.

#-----start----
#! /bin/bash
#To stop the tomcat
/etc/init.d/tomcat stop
#To copy  CATALINA.out to  CATALINA1.OUT & remove. All in one shot
mv /tmp/CATALINA.out  /tmp/ CATALINA1.OUT
#To run the tomcat
/etc/init.d/TOMCAT start
#-----end---

Ok, i have edit script by using vi, but i haven't create an executable after command:

chmod +x myshell.sh

i have also myshell.sh in path of creation an run script (only calling it?) having error:

-su: myshell.sh: command not found

On the moment you did the command chmod +x myshell.sh, it has turned to a executable file. There is no exe file concept in linux.

while running from same directory use ./myshell.sh not myshell.sh
 
oK, WITH LAST INDICATION I HAVE SOLVING THE PROBLEM!
Thanks a lot. Claudio.