cronjob help
Hi I am very new to linux. I want to run a cronjob every 15 minutes that checks a directory for files. If the directory contains more than ten files I want it to send an email to me.
All I have is this... */15 * * * * ls -l | wc -l | [filename] | mail -s "This is just a test" [email address] I would rather not write a bash script. Is there an easier way to do this? I was looking into some commands like find and grep Could you show me an example? Thanks, LN |
What's that [filename]?
|
I meant to say the current directory.
|
My problem is the area where it says... when it exceeds 10 files send an email. The files in the directory will fluctuate.
|
I still don't know what you mean by [filename], you can't pipe to a filename. You would need something like this:
Code:
ls -1 /path/to/dir | wc -l | mail -s "subject" "name@domain.net" |
I'm so new...to this.
I don't know how to write a script for this. How do I incorporate all this to email myself when this stuff happens? #!/bin/bash if [ [ls -l | wc -l] > 10 ]; then mail -s [email address]; fi I have no way to test this, until I'm in school. Thanks for the help. |
You have a great way to test this: install Linux =)
Code:
#!/bin/bash Here's a great reference: http://www.tldp.org/LDP/abs/html/ |
All times are GMT -5. The time now is 09:25 PM. |