Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 15th September 2009, 16:50
sc30317 sc30317 is offline
Junior Member
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help writing a shell script/cron job

Here is my issue:

I have to write a shell script that archives pictures stored in a directory.

within my /home/pictures directory, jpegs get saved.

Once the folder gets large enough (100MB), I would like to make a tar.gz archive all the files located in the directory, and move them to /home/archives.

How would I go about writing a shell script/cron job to perform this?
Reply With Quote
Sponsored Links
  #2  
Old 15th September 2009, 19:31
sc30317 sc30317 is offline
Junior Member
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here is what I have so far:
Code:
#!/bin/bash
# Backup Script

echo "\nWelcome to the backup script\n"
cd /home/images

if [$du -h /home/images] >= 100MB ; then
   tar -pczf `date`.tar.gz /home/pictures/backup
fi

exit 0;
This doesn't work right.
Reply With Quote
  #3  
Old 15th September 2009, 20:03
Franz Franz is offline
Senior Member
 
Join Date: Jul 2009
Location: Cakovec
Posts: 117
Thanks: 7
Thanked 24 Times in 18 Posts
Send a message via Skype™ to Franz
 
Default

Try this



Code:
#!/bin/bash
# Backup Script

echo "\nWelcome to the backup script\n"
path="/home/images"

if [ `du -ms $path` > 1000 ] ; then
        find $path > /tmp/list.txt
        tar -T /tmp/list.txt -pczf `date`.tar.gz
        for i in `cat /tmp/list.txt`; do
                rm -rf $i
        done
fi

exit 0;
__________________
my PAGE
VoIP
my IT help blog
Reply With Quote
Reply

Bookmarks

Tags
shell scripts

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Broken pipe: core_output_filter: writing data to the network memphis Server Operation 2 19th July 2007 14:36
Need help for writing shell script chris_87 Programming/Scripts 7 4th April 2007 15:50
need urgent help for writing shell script dips Programming/Scripts 8 3rd September 2006 19:40
Need help for writing shell script erez Programming/Scripts 4 16th June 2006 14:23
Shell nveid General 5 27th March 2006 14:49


All times are GMT +2. The time now is 02:04.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.