1. Stay away from the backticks! Instead of date2=`date +%Y%m%d` use date2="$(date +%Y%m%d)"
2. Use shell means wherever possible, it is way faster:
the same in shell code:
3. Unnecessary variables: you don't need "$date1" simply write:
4. Why do you run the script every two minutes? Wouldn't it be easier to run it permanently (as a daemon)?
This will process all the files there are, wait 60 seconds if there are none and then check again, etc..
Thanks everyone. I incorporated suggestions made by bakunin, methyl and macnamare and added below if condition inside for loop. Its working fine in my test script and I believe this should fix the problem.
I wish to know whether find command above is fine or it should be modified.
The script idea in post #9 will fail if no files are found.
If we take the original script from post #1, we can build the condition in.
Something like this (untested):
This assumes that there are no subdirectories under "/one/two/three/four". If there are subdirectories, the find will need a -maxdepth parameter to stop it descending the tree.
I've also added/moved a lot of double quote characters and delimited all Environment Variables with curly brackets (always good practice).
Also changed the for loop to a [icode]while[icode] loop because for loops are prone to failure.
Our comp-operator has come across a peculiar ‘feature'. We have this directory where we save all the reports that were generated for a particular department for only one calendar year. Currently there are 45,869 files. When the operator tried to backup that drive it started to print a flie-listing... (3 Replies)
what is wrong with the below script:
---------------------------------------------------------------------------------
#!/bin/bash
echo "Setting JrePath..."
grep -w "export JrePath" /etc/profile
Export_Status=$?
if
echo "JrePath declared"
elif
echo "JrePath not declared"
echo... (4 Replies)
This is an unusual situation where I have an NFS server currently serving out MULTIPLE clients over several variants of Linux and UNIX successfully (world permissions) except for a SINGLE client. Even the other Linux (SuSE) clients in the same room are mounting successfully with defaults without... (6 Replies)
I'm making a program that you input the month and year, and it creates a calender for that month of that year. This is my largest project yet, and I broke it up into several source files.
cal.c
#include "cal.h"
#include <stdio.h>
main() {
int month, year;
scanf("%d %d", &month,... (3 Replies)
is there anyway to make while run a command faster than per second?
timed=60
while
do
command
sleep 1
done
i need something that can run a script for me more than one time in one second. can someone help me out here? (3 Replies)
Helllo folks...
I tryed to edit crontab and I have this problem when I do crontab -l it shows my crontab correctly and if I do crontab -e I get this.
baafh-99.03#
baafh-99.03# crontab -e
1063
?
?
?
?
?
and that is all ...:( I have to type "q" and hit enter and I am back... (4 Replies)
I'm wrting a program which needs to get the following information of a sever by calling some lib fuctions or system calls, so can anybody help to tell me those function names or where I can find the description of them ?
CPU usage
Memory usage
Load procs per min
Swap usage
Page I/O
... (11 Replies)
I'm wrting a program which needs to get the following information of a sever by calling some lib fuctions or system calls, so can anybody help to tell me those function names or where I can find the description of them ?
CPU usage
Memory usage
Load procs per min
Swap usage
Page I/O
Net I/O... (1 Reply)
i'm a relative newbie to unix (i'm on OSX) and i have a specific problem i'm tripped up on:
i'm piping the output of top (in log format) into an awk command which formats the information (and eventually will send it out continuously via udp/osc to another app). my problem is with what comes up... (4 Replies)