Script to delete logs or take backups under specific user


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to delete logs or take backups under specific user
# 8  
Old 01-24-2008
Your script is expecting an existing directory to be given as the backup location.

Also pls try to run the script as below and post the output
yourscript -a backup -l /tmp/Debug

Make sure that you have created /tmp/Debug before running the script,at the end of the run,check if see any directory named backup under /tmp/Debug

Thanks
Nagarajan G
# 9  
Old 01-24-2008
Quote:
Originally Posted by ennstate
Your script is expecting an existing directory to be given as the backup location.

Also pls try to run the script as below and post the output
yourscript -a backup -l /tmp/Debug

Make sure that you have created /tmp/Debug before running the script,at the end of the run,check if see any directory named backup under /tmp/Debug

Thanks
Nagarajan G


I have tried the script like this and specified an existing directory but it is nt creating any backup under that.
i got this when i ran the script--

mt_clean -a backup $INTAS/INSTALL_DIR/mt_backup now
Specify the backup Location
Unable to locate mt_clean in the PATH, check the .kshrc for correctness
# 10  
Old 01-24-2008
Quote:
Originally Posted by namishtiwari
I have tried the script like this and specified an existing directory but it is nt creating any backup under that.
i got this when i ran the script--

mt_clean -a backup $INTAS/INSTALL_DIR/mt_backup now

Specify the backup Location
Unable to locate mt_clean in the PATH, check the .kshrc for correctness
You haven't specified the option -l before providing the backup location.Also don't provide the backup location with the pattern "backup" in that.

Also you have not defined INTAS/ INSTALL_DIR,so its better to test with /tmp/Debug directory and see what happens,


Thanks
Nagarajan G
# 11  
Old 01-24-2008
-l option is not required because i have changed the script a bit and pasted in this thread only.so -l option is not required.

$INTAS_INSTALL_DIR is a variable for a directory subsitution.
when i ran the script without backup in the dir name

mt_clean -a backup /tmp/debug now

it did not through any error and did not even created the debug dir also.
i am using HP-UX.
# 12  
Old 01-24-2008
shift your input parameters at getopts.
# 13  
Old 01-25-2008
I have done some changes in the script--
Code:
l) BackupLocation="$OPTARG"
		if [[ $BackupLocation != *backup ]]; then
			echo "Appending backup subdirectories"
			BackupLocation=$BackupLocation/backup
			mkdir -p $BackupLocation >/dev/null 2>&1
                        if [[ $? != 0 ]];then
                        echo "First Create The Directory And Then Take backup"
                        fi
                        cp $FilesToDelete $BackupLocation
                        for files in $FileLocation
                        do
                           touch $files $files.$(date +%a)
                           rm -f $FilesToDelete
                        done
                else
                        mkdir -p $BackupLocation >/dev/null 2>&1 
                        cp $FilesToDelete $BackupLocation
  		if [[ ! -d $BackupLocation ]]; then
    		echo "Unable to make backup directory: $BackupLocation"
        		if [[ $IsCronJob -eq 1 ]]; then
	  		  SendMiddleTierCleanMail "Middletierclean error message" $mt_clean_errfile
			fi
			return $E_INT_MISSING_DIR
  		fi
		fi
		l_flag=Y
		Llcron=l
		;;

I am getting error ----

cp: cannot access *.log*: No such file or directory
before that it was working fine.I only copied from one dir to another.
But now it is not working under in any of the directory.touch is also not working.please give me some suggestion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. Shell Programming and Scripting

Shell script to delete empty files from specific locations

Hi, I need help in regard to developing a shell script to delete empty files from multiple specific locations. The directory paths will be stored in a text file. So the requirement is to read the text file for one specific path and then remove empty files from that particular path. Looping through... (4 Replies)
Discussion started by: Khan28
4 Replies

3. Shell Programming and Scripting

Script to compress and delete the older logs

Hello Guys, Can you please help me with a script which zips the older log files(1-2 weeks) and delete them? I want to run the script manually instead of setting it up in a cron job. Appreciate your help. Regards, Kris (6 Replies)
Discussion started by: kriss.gv
6 Replies

4. Shell Programming and Scripting

Script to append user details as soon as he logs in

I'm wishing to create a log myself where I wish to: 1.Write a script in /bin folder to make a separate log in var/log folder & 2.Call the script in bashrc each time a user logs in, I'm trying to avoid CRONJOB as it would take too much of my memory after iterations. So I just need to append the... (2 Replies)
Discussion started by: Lionking93
2 Replies

5. Shell Programming and Scripting

How to make a script that logs bandwidth on a specific port?

I have a script that runs right before a daily reboot that captures the amount of MB transmitted up and pulled down since last reboot. echo `date +"%m-%d-%y"``grep eth0 /proc/net/dev | awk '{print ","$2/1024/1024","$10/1024/1024}'`>>/home/nick/bandwidth.logIn looking at the raw output of... (1 Reply)
Discussion started by: nbsparks
1 Replies

6. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

7. Shell Programming and Scripting

How to automatically delete old backups

I'm creating nightly backups using cygwin bash with this one line script: zip -r "K:/backup/outlook/`date "+%y%m%d%M"`" C:/Documents\ and\ Settings/siegfried/Local\ Settings/Application\ Data/Microsoft/Outlook How can I enhance my script using the "rm" command so I never have more than 4 zip... (2 Replies)
Discussion started by: siegfried
2 Replies

8. Shell Programming and Scripting

Create a script that executes when a user attempts to delete history logs

Hi, I have a linux redhat 9 server and I am concerned about the security on that server. I would like to be able to write a script that records all the commands that were typed at the command prompt before the user calls the 'history -c' command and deletes all the history. I was thinking about... (4 Replies)
Discussion started by: mishkamima
4 Replies

9. UNIX for Dummies Questions & Answers

Script to change/find/delete/install a specific file

Hi Very much a newbie to UNIX & scripting, but have identified an area within work that would benefit from being automated, as its repeated manually very often, and it looks like the ideal first script! What I need to do is change directory to a users home (cd ~), and then find and remove a... (6 Replies)
Discussion started by: Great Uncle Kip
6 Replies

10. Shell Programming and Scripting

Batch delete specific folder from user home directories

Hi! Need your help. How can I delete the cache folder of multiple user home directories via automatically executed shell script on a Mac OS X Server? Example: The userdata are stored on a Xsan Volume like this: /Volumes/Xsan/userdata/mike /Volumes/Xsan/userdata/peter... (2 Replies)
Discussion started by: nipodrom
2 Replies
Login or Register to Ask a Question