fileName=Device_manumodel_DATETIME.csv .
in another server client will put files like Device_manumodel_yyyymmddhhmi.csv format. every 30 mins script will run and took the file from client server.
You also need to ensure that your file creation and all the output being put into it is Atomic, i.e. a single operation that takes a single IO. Often this is done by creating the file and building it up with content as another name and then when it is ready, renaming it to it appears as a complete file instantly.
If you have a file that takes even a whole second to build, then you may sometimes be unlucky and fetch a partial file.
Something like this would illustrate it:-
((random_delay=$RANDOM%9))
( sleep $random_delay ; cat /tmp/myfile ) & # Display the file at some undetermined time
date > /tmp/myfile
echo "First data line of file" >> /tmp/myfile
sleep 3
echo "Second data line of file" >> /tmp/myfile
sleep 3
echo "Last data line of file" >> /tmp/myfile
wait # In case the random delay is long, wait for the background sleep/cat to finish
If you run this repeatedly, you may get 1, 2 or 3 lines of output. You can compensate by the cat reading a file that is always the finished article, so more like:-
((random_delay=$RANDOM%9))
( sleep $random_delay ; cat /tmp/finalfile ) & # Display the file at some undetermined time
date > /tmp/myfile
echo "First data line of file" >> /tmp/myfile
sleep 3
echo "Second data line of file" >> /tmp/myfile
sleep 3
echo "Last data line of file" >> /tmp/myfile
mv /tmp/myfile /tmp/finalfile # Atomic file write
wait # In case the random delay is long, wait for the background sleep/cat to finish
It may fail first time if the file does not exist, but afterwards it would only ever read a completed file.
Doing this, you could also make a link as a "latest" file, so you always know which one to pick up.