LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-25-2006, 07:11 PM   #1
samw5
LQ Newbie
 
Registered: Feb 2006
Posts: 28

Rep: Reputation: 15
Script for folder emptiness?


Hey guys, I'm trying to write a script that will automatically move images onto a different folder.

I have noway of knowing when the images are available (they are uploaded via FTP whenever I need so there isn't a schedule). That's the reason why I have the script scheduled as an hourly cron. So once I upload the pictures (remotely) it moves them at the end of the hour (and I can access them via apache).

Now the problem I am having is with message logs. The upload folder is most of the time empty and the mv command will dumb a message on screen which in turns gets sent to root. I don't want any kind of logs of the transaction.

Tried to remove the mail option in the crontab w/o any success. Tried dumping the output to /dev/null
1$2>/dev/null

no luck either. I'm just not sure why it's even sending logs like this... and how to stop them (definitely not an otpion in the syslog either).

Any ideas?
Sam
 
Old 04-26-2006, 04:03 AM   #2
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,492

Rep: Reputation: 50
have you tried
commandoutput >/dev/null 2>&1


you could put that in cron or in the script......
 
Old 04-26-2006, 04:14 AM   #3
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Code:
if [[ -n "$(ls /what/ever/path)" ]]; then
        mv ...
fi
 
Old 04-26-2006, 04:50 AM   #4
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,492

Rep: Reputation: 50
yes, it might just be easier to use "test" to check if there is anything there.

in the above it's checking if "ls /yourfiles/" is not null (i.e empty). If it is then it runs the script. Otherwise it does not...
 
Old 04-26-2006, 11:03 AM   #5
samw5
LQ Newbie
 
Registered: Feb 2006
Posts: 28

Original Poster
Rep: Reputation: 15
sweet, I knew it shouldn't be something hard... My dumbself was trying to use the find function to run a test on the folder... didn't even think about just listing stuff.

Anyways, thanks all for the great tips!
Sam
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script to empty /tmp folder capnp72 Linux - General 8 02-15-2006 12:50 PM
how to run a script on subfolder file in a folder saggi_sam Linux - Newbie 5 07-13-2005 05:04 AM
Script to change folder permissions waitingforOES Linux - Newbie 1 03-07-2005 01:34 PM
How to copy in a script files to a samba folder? Julianus Linux - Networking 1 10-09-2004 07:29 PM
help on web folder script evilchild Programming 1 11-22-2003 07:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration