Solved

Synchronize then delete remote directory using SSH-SFTP program or Linux (Centos) command lines

Posted on 2013-01-10
5
1,103 Views
Last Modified: 2013-01-24
Hello Experts,

I have a PBX system which has very limited capacity for call recording that will not last for more than a week probably.

I'm using WinSCP through SFTP (SSH Based on port 22) at the moment to sync remote folder to my PC,  but I have to do this manually each week to sync the recording folder, then delete its remote contents so the PBX can start recording again.

I would like to know if there's any other application that would schedule Synchronization through SSH - SFTP and then delete the remote directory contents. and incase there's not. is there anyway to do this through Centos command lines? as The PBX has also support to USB external storage and I would also be glad if I could schedule moving the recording folder contents from a directory path into another.

Thanks a lot



Thanks
0
Comment
Question by:Mohammed Hamada
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 250 total points
ID: 38763097
you can run a crontab job to copy then truncate the file

/usr/bin/cp /path/to/yourfile /path/to/somedir/filename
> /path/to/yourfile

put above two lines in a file, say myscript

make it executable

chmod +x myscript

then run

crontab > mycron

echo '59 23 * * * /path/to/myscript' >> mycron

crontab mycron
0
 
LVL 24

Author Comment

by:Mohammed Hamada
ID: 38763363
Salam Omar,

Would this allow the executable script file to be scheduled for weekly run?
thanks
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 38763387
you can change the last * into the day of week you want like


59 23 * * 0 /path/to/myscript

here 0 is for Sunday or you can put 1 for Monday, 2 for Tue etc.
0
 
LVL 16

Assisted Solution

by:AlexPace
AlexPace earned 250 total points
ID: 38763994
You could use a Robo-FTP script installed as a service to just download the files as they appear on the remote site.  See: http://kb.robo-ftp.com/script_library/show/69
0
 
LVL 24

Author Closing Comment

by:Mohammed Hamada
ID: 38816018
thanks
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question