Advertisement

[x]
Attachment Details

Looking for some help constructing a shell script

I am a complete noob at shell scripting.  I have a business that wants record after hours activity via dgital wifi security camera's due to theft.

I devised a method that would use DCS 5300G IP cameras to upload their data to an off-site location via FTP.

This works but now, I am having some issues with the crontab commands I have setup to create a daily archive of the data via the web hosting company's cPanel.  Unfortunately, the webhosting company's support team is not able to decipher the crontab(so they say) to troubleshoot the issue.

How can I turn this all in to a shell script that can run against each directory of files and perform the same steps outlined below.

I created the following entries:
- 0 9 * * *
this stands for run every day at 9am, based on the server's time

- This command will zip all .jpg files found in the path: /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL

- 0 9 03 * * *
this stands for run every day at 9:03am, based on the server's time

- This command will delete all .jpg files in the path rm /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL

- 0 9 06 * * *
this stands for run every day at 9:06am, based on the server's time

- This command will move the .zip file from the /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL directory to /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

mv /home/nrrcom43/public_ftp/tarcam/tbs-cam-1FL/tbs-cam1FL.zip /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

- 0 9 09 * * *
this stands for run every day at 9:09am, based on the server's time

- This command will execute a shell script which will append today's date to the zip file that was moved in the previous step above. This script was tested by one of your techs in this ticket but it is not running properly from my crontab.

sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/addDate.sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/tbs-cam-1FL.zip

- 0 9 12 * * *
this stands for run every day at 9:12am, based on the server's time

- This command will zip all .jpg files found in the path: /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL



- 0 9 15 * * *
this stands for run every day at 9:15am, based on the server's time

- This command will delete all .jpg files in the path rm /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL


- 0 9 18 * * *
this stands for run every day at 9:18am, based on the server's time

- This command will move the .zip file from the /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL directory to /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

mv /home/nrrcom43/public_ftp/tarcam/tbs-cam-2FL/tbs-cam2FL.zip /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives

- 0 9 21 * * *
this stands for run every day at 9:21am, based on the server's time

- This command will execute a shell script which will append today's date to the zip file that was moved in the previous step above. This script was tested by one of your techs in this ticket but it is not running properly from my crontab.

sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/addDate.sh /home/nrrcom43/public_ftp/tarcam/tbs-cam-archives/tbs-cam-2FL.zip

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
This is the content of the .sh file
 
#! /bin/sh
 
filefullname=$1
filename=${filefullname%.*}
fileext=${filefullname##*.}
 
DATETIME=`date +%Y%m%d`
 
newfilename="${filename}${DATETIME}.${fileext}"
 
mv $filefullname $newfilename
Related Solutions
Related Solutions
 
Loading Advertisement...
 
Expert Comment by nognew:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 

Rank: Master

Expert Comment by Tintin:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by nappy_d:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by nognew:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 

Rank: Master

Expert Comment by Tintin:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by lanboyo:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by lanboyo:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
Loading Advertisement...
20080924-EE-VQP-41 / EE_QW_2_20070628