when it runs and look at my acron.log file it generates an error as below
/tmp/prog.sh: line 4: [1: command not found
/tmp/prog.sh: line 7: 1=1: command not found
head: cannot open `samp.csv' for reading: No such file or directory
sed: can't read samp.csv: No such file or directory
tail: cannot open `samp.csv' for reading: No such file or directory
tac: cannot open `samp.csv' for reading: No such file or directory
split: cannot open `samp.csv' for reading: No such file
Which shell are you using? Has the command executed successfully?
Try running the script manually and check whether the value of $run is being incremented correctly.
If you face any issues, Try replacing let run=($(cat a.log)+1) with run=$(( $(cat a.log)+1 ))
Don't have it started by cron every minute. Run it once, execute a loop 10 times, sleep for not quite a minute in that loop, and exit gracefully.
And, why don't you give us a broader picture of what you want to achive? We might be able to help you better, then, instead of supplying bits and pieces here and there...
If I understand what is going on in this thread, you have changed references in your script to use absolute pathnames when your read and write samp.csv, but it sounds like you are not using an absolute pathname when you read and write a.log. Unless you add a cd command at the start of your script to move into the directory where all of these files reside, you have to use absolute pathnames in all references to all input and output files.
How are you initializing the contents of /full/path/to/a.log?
It's nearly always best to use the absolute path name in scripts, for all filenames, including commands.
First of all, if you don't use a full path, then it's possible another file can be executed that is in the search path; and this can cause numerous problems, including security issues.
Second, if you refuse (for some odd reason), to use the full path name, you should define your search path explicitly in the script, for the same reasons.
In this example, the poster is writing from cron as a user that he has not defined (for us). It's possible he could be running it as a root crontab.
The original poster should rewrite the script using the full path to all files (commands, logs, input files, etc.) and he should inform what user crontab is running this script.
He should also list each file that is read and written to with ls -l so we can see the permissions of the files.
i think it is best when working the problems to get the correct and full information instead of just grasping at straws and pulling bits and pieces of information from the member with the problem.
The user will also learn more, I think, if we ask them to provide the right information up front, define his paths correctly (all paths), etc. .. in my view.