Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: ubuntu 14.04 lts directory cleanup script "ip cam"  (Read 5443 times)

0 Members and 1 Guest are viewing this topic.

snowcatman

    Topic Starter


    Beginner

    • Experience: Beginner
    • OS: Windows 8
    ubuntu 14.04 lts directory cleanup script "ip cam"
    « on: April 22, 2014, 09:32:06 PM »
    I am very new to linux unix ubuntu what ever. i am running on an old: inspiron 530s, 991.5 MiB RAM, Intel® Pentium(R) Dual CPU E2160 @ 1.80GHz × 2, Intel® G33 x86/MMX/SSE2, 32-bit OS, disk 77.6 GB.

    i think i would need a step by step instruction on how to create a script. to maintain a directory. it can only get so full and old files can be deleted to maintain the directory. i am using 2 easyn ip cam's and ftp into this machine. i have it forwarding to the ftp every second.

    my ftp is pureftp server -- pureadmin v0.4 for gui

    i made a directory in my home directory that the ftp puts the files.
    /dadscam
    in that directory is.
    /cam1
    /cam2

    unless there is a program already out there i think i need a script.

    thank you

    i am still searching google. put don't see anything user friendly or step by step. sorry if i annoy you with this thread.
    « Last Edit: April 22, 2014, 10:27:58 PM by snowcatman »

    snowcatman

      Topic Starter


      Beginner

      • Experience: Beginner
      • OS: Windows 8
      Re: ubuntu 14.04 lts directory cleanup script "ip cam"
      « Reply #1 on: April 23, 2014, 07:51:42 AM »
      I would like to add some info.

      the picture file names go something like this:

      00A00107151A(IP\ Camera\ 2)_1_20140422200106_2852.jpg
      file size are approximately  50.1kb
      I am using approximately 8gb out of 66gb of hard drive  from 6gb in the last 12 hrs

      i think i have more of a ram problem then a hard drive issue. i found this out by trying to access the cam1 directory threw the GUI. wow it stalled or lagged. but it seemed a lot easier access threw the terminal.

      snowcatman

        Topic Starter


        Beginner

        • Experience: Beginner
        • OS: Windows 8
        Re: ubuntu 14.04 lts directory cleanup script "ip cam"
        « Reply #2 on: April 23, 2014, 05:40:58 PM »
        Well i looked up some other scripts in hopes to get close too what i am looking for. so here is what i found and have.

        =====================================================================
        #!/bin/bash
        # ip-cam-ftp-cleanup.sh
        #    _______    __    __    ________    _________
        #   /  ___  \  |  |  |  |  |   __   |  /
        #   \  \  \_/  |  |  |  |  |  |  |  |  |
        #    \  \      |  | /   |  |  |  |  |  |
        #     \  \     |  |/    |  |  |  |  |  |      snowcatman
        #      \  \    |        |  |  |  |  |  |
        #       \  \   |    /|  |  |  |  |  |  |
        #    _   \  \  |   / |  |  |  |  |  |  |
        #   / \__/  /  |  |  |  |  |  |__|  |  |
        #   \______/   |__|  |__|  |________|  \_____________
        #
        # ====================================================================
        # modified script

        #log this to a the local BASH file directory
        # logger -s "foo bar" 2>> ~/bin/ip-cam-ftp-cleanup-log1.txt
        # >>$ip-cam-ftp-cleanup-log2.txt 2>&1
        #ip-cam-ftp-cleanup.sh >> ~/bin/ip-cam-ftp-cleanup-log3.txt 2>&1

        #------------
        #write_log()
        #{
        #  while read text
        #  do
        #      LOGTIME=`date "+%Y-%m-%d %H:%M:%S"`
        #      # If log file is not defined, just echo the output
        #      if [ "$LOG_FILE" == "" ]; then
        #    echo $LOGTIME": $text";
        #      else
        #        LOG=$LOG_FILE.`date +%Y%m%d`
        #    touch $LOG
        #        if [ ! -f $LOG ]; then echo "ERROR!! Cannot create log file $LOG. Exiting."; exit 1; fi
        #    echo $LOGTIME": $text" | tee -a $LOG;
        #      fi
        #  done
        #}
        #------------

        #need to add a indicator for how long the proccess might take.


        # Show were trash can is.
        TRASHCAN=~/.local/share/Trash/files

        # Send to TrashCan
        # find ~/dadscam/* -mtime +2 -exec mv {} $TRASHCAN \;
        find ~/dadscam/* -mmin +2880 -exec mv {} $TRASHCAN \;

        # Send to Death
        # find $TRASHCAN* -mtime +3 -exec rm {} \;
        find $TRASHCAN* -mmin +4320 -exec rm {} \;

        # ====================================================================
        #
        #            +-+-+-+-+-+-+-+
        #            |c|r|e|d|i|t|s|
        #            +-+-+-+-+-+-+-+
        #   http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

        # My name is Shawn Quintal A.K.A. Online SnowCatMan
        # [email protected]
        # This is my first script.
        # Using native to ubuntu 14.04
        # This is a BASH script
        # I got the examples from http://gotbletu.blogspot.com/ | http://www.youtube.com/user/gotbletu timebomb.sh
        #
        =============================================================================

        i am looking to get the -mtime to hours if possible i thought i saw some were with a like 24h or something??? ok modified this found -mmin +300 it workes so far.
        « Last Edit: April 23, 2014, 06:40:46 PM by snowcatman »

        snowcatman

          Topic Starter


          Beginner

          • Experience: Beginner
          • OS: Windows 8
          Re: ubuntu 14.04 lts directory cleanup script "ip cam"
          « Reply #3 on: April 23, 2014, 07:20:36 PM »
          added to startup in ubuntu


          1.
          gksudo pureadmin


          2.
          ip-cam-ftp-cleanup-auto-on.sh

          in that file is...
          =============================
          #!/bin/sh
          #ip-cam-ftp-cleanup-auto-on.sh
          while [ true ]
          do
              sh ip-cam-ftp-cleanup.sh
              sleep 60
          done
          =============================

          now i think i got it. and no help. just google and examples. if anyone has questions please do ask. i may learn something if you do. :-)