?
Solved

Solaris Script and Cron

Posted on 2003-03-09
7
Medium Priority
?
237 Views
Last Modified: 2013-12-27
Hi,

1. Is there any books or web sites you can recommend me on how to write Unix script (basic)?
2. Right now, i need to write a script to cp two huge files from one directory to another directory and zip, how to begin?

cd  /abc/backup
mkdir <date of creation>
cd <date of creation>
cp -p /efg/a50_5/log/pc* .
cp -p /efg/a50_5/log/sc* .
gzip *

 
Thanks in advance.

0
Comment
Question by:terrywong
[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
  • 2
  • +1
7 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 240 total points
ID: 8100808
1. For learning shell scripting, have a look at the following pages:

http://steve-parker.org/sh/sh.shtml
http://www.codebox.8m.com/shellscripting.htm

2. A example script for your question:

#!/bin/sh
TODAY=`date +%Y%m%d` # format 20030310
cd  /abc/backup
mkdir $TODAY
cp -p /efg/a50_5/log/pc* .
cp -p /efg/a50_5/log/sc* .
gzip *
exit

# End of Script

Cheers!





0
 
LVL 38

Expert Comment

by:yuzh
ID: 8100816
If you are running an older version of Solaris (7 or older), you need to put the full path for gzip in the script.

eg:

/usr/local/bin/gzip *
0
 
LVL 10

Expert Comment

by:elf_bin
ID: 8101799
I do it like this:
#!/bin/sh

DAY=`date +%a-%d-%m-%y` # Can change format (see man date)

cd /abc/backup
mkdir $DAY
cd $DAY
cp -p /efg/a50_5/log/pc* .
cp -p /efg/a50_5/log/sc* .
/usr/bin/gzip *

The `` are escape characters that make the command run & the output of that is assigned to the variable DAY (we don't export the variable day, since we don't need it in any other script).

Hope this helps.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 21

Expert Comment

by:tfewster
ID: 8101918
To save temporary space & time, try this instead of "cp then gzip" in your script.

for file in `ls efg/a50_5/log/pc*`
do
  gzip -c $file > `basename $file`.gz
done

The syntax may need to be different, depending on your shell.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8207904
terrywong,

It's time to clean up this topic area. Please respond to the Experts' comments.

EXPERTS: Apparently, the Asker has abandoned this question. Please leave your thoughts on the resolution of this question here.

Netminder
EE Admin
0
 
LVL 21

Expert Comment

by:tfewster
ID: 8208032
Answered by yuzh
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8208397
Force-accepted.

Netminder
EE Admin
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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 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