Sponsored Content
Top Forums Shell Programming and Scripting shell script to remove old files and write to a log file Post 302197221 by yabai on Tuesday 20th of May 2008 12:15:12 PM
Old 05-20-2008
shell script to remove old files and write to a log file

Hi,

I have a script that works on a unix box but am trying to get it working on a linux box that uses shell. I am not a programmer so this is proving harder than I imagined. I made some changes and ended up with the script below but when I run it I get the following messages. Any help would be great.

messages
./cleanoldbackups.sh: line 18: syntax error near unexpected token `fi'
./cleanoldbackups.sh: line 18: `fi '


script
# -----------------------------------------------------------------------
2>&1
# -----------------------------------------------------------------------
# Check run type - r report, d delete
# -----------------------------------------------------------------------
set RUN_TYPE= $1
if [! [$RUN_TYPE == 'r' || $RUN_TYPE == 'd']] then
echo "Invalid parameter" $RUN_TYPE
exit
fi
#
# -----------------------------------------------------------------------
# Set local variables
# -----------------------------------------------------------------------
set LOGFILE= /exlibris/dtl/d3_1/log/cleanoldbackups.log.`date '+%Y%m%d_%H%M%S'`
# -----------------------------------------------------------------------
# Switch to backup directory. Find and report/delete files
# -----------------------------------------------------------------------
cd /directory/backup
#switch $RUN_TYPE
case r
find . -atime +8 | sort | xargs ls -l >>$LOGFILE
breaksw
case d
find . -atime +8 -exec rm {} \; >>$LOGFILE
esac
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to write Flat Files by shell script using Oracle Database

Hello There.. I came to a situation where I need to write flat files using shell scripts, I need to pull the records from the oracle database and create the flat file, This process should be automated. Can any shell script expert out here to help me.. please.. Will be really glad to... (3 Replies)
Discussion started by: coolbuddy
3 Replies

2. UNIX for Advanced & Expert Users

Script to Extract time from log files and write to a excel

Can someone help me with writing a unix script for following requirement 1) I have a log file in which we have start time and end time (format: hh:mm:ss) Example: starting script on Thu Jun 5 20:50:52 Thu Jun 5 21:55:33 - Script Completed 2) I want to extract start time and end time of... (0 Replies)
Discussion started by: santosham
0 Replies

3. Shell Programming and Scripting

Script to Extract time from log files and write to a excel

Can someone help me with writing a unix script for following requirement 1) I have a log file in which we have start time and end time (format: hh:mm:ss) Example: starting script on Thu Jun 5 20:50:52 Thu Jun 5 21:55:33 - Script Completed 2) I want to extract start time and end time of... (0 Replies)
Discussion started by: santosham
0 Replies

4. UNIX for Dummies Questions & Answers

Script to Extract time from log files and write to a excel

Can someone help me with writing a unix script for following requirement 1) I have a log file in which we have start time and end time (format: hh:mm:ss) Example: starting script on Thu Jun 5 20:50:52 --------- Thu Jun 5 21:55:33 - Script Completed 2) I want to extract... (4 Replies)
Discussion started by: santosham
4 Replies

5. Shell Programming and Scripting

To write a shell script which groups files with certain pattern, create a tar and zip

Hi Guru's, I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files. For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies

6. UNIX for Dummies Questions & Answers

Create a shell script for write files with 2 parameters

Hello, I'm a newbie in shell script. So, i would like to create a shell script which take 2 IN parameters (PARAM1 and PARAM2). This script need to create 2 files as : I need to create this file /etc/apache2/sites-available/PARAM2 : <VirtualHost *:80> DocumentRoot "/home/PARAM1/www"... (0 Replies)
Discussion started by: chatlumo
0 Replies

7. Shell Programming and Scripting

Write an automated shell program(s) that can create, monitor the log files and report the issues for

Hi , Please help me getting this done. Write an automated shell program(s) that can create, monitor the log files and report the issues for matching pattern. (i) Conditions for creating log files. Log file is created with date (example 2010_03_27.log). If the log file size is 10 Mb for... (1 Reply)
Discussion started by: itian2010
1 Replies

8. Shell Programming and Scripting

How to write a shell script to display files in single path?

Hello friends, I am a script which dispalys a multiple files with their contents. for exm: suppose two file test1.txt and test2.txt. when I run my script it have to display the below O/P. test1.txt -rw-r----- 1 sranga staff 91 Sep 23 02:18 calc.sh -rw-r----- 1 sranga ... (2 Replies)
Discussion started by: sivaranga001
2 Replies

9. Shell Programming and Scripting

Need help to write a script for moving the log files to some other folder

Hi Experts, I want to write a script, based upon the following requirement 1) I am having 5 application $ cd logs $ ls -l drwxr-xr-x 2 natraj nat 5.0K Sep 20 10:25 one drwxr-xr-x 2 natraj nat 5.0K Sep 20 10:39 two drwxr-xr-x 2 natraj nat 1.5K Sep 20 10:58... (4 Replies)
Discussion started by: natraj005
4 Replies

10. Shell Programming and Scripting

Need help to write to log file whether the shell script call pass fail

I have the below script triggered daily at 330am in the morning, since last 7 days job not writing anything to database. below impala shell calling shell file which has sql , it is extracting data and loads to a flat file txt file. which is going wrong for last 1 week. need help, echo... (2 Replies)
Discussion started by: cplusplus1
2 Replies
BBACKUPD-CONFIG(8)						    Box Backup							BBACKUPD-CONFIG(8)

NAME
bbackupd-config - Box Backup client daemon configuration file generator SYNOPSIS
bbackupd-config config-dir backup-mode account-num server-hostname working-dir backup-dir [backup-dir ...] DESCRIPTION
The bbackupd-config script creates configuration files and client certificates. It takes at least six parameters: config-dir Configuration directory. Usually /etc/box. backup-mode Either lazy or snapshot. account-num The client account number. This is set by the bbstored administrator. server-hostname The hostname or IP address of the bbstored server. working-dir A directory to keep temporary state files. This is usually something like /var/bbackupd. This can be changed in bbackupd.conf later on if required. backup-dir A space-separated list of directories to be backed up. Note that this does not traverse mount points. FILES
/etc/box/bbackupd.conf /etc/box/bbackupd/NotifySysAdmin.sh SEE ALSO
bbackupd.conf(5), bbackupd(8), bbackupctl(8) AUTHORS
Ben Summers Per Thomsen James O'Gorman Box Backup 0.11 10/28/2011 BBACKUPD-CONFIG(8)
All times are GMT -4. The time now is 01:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy