Home > Software design >  Want to store a value in local ../usr from shell script
Want to store a value in local ../usr from shell script

Time:12-12

I just want to store some values while running shell script , scenario : if im running shell script it will do some operation and it will store the results/activity done. then again I'm running the same script I should identify these are executed and you can continue from here . some what I need . how to do that? can we use .lock file or else any other best ways are there?

I just want to store some values while running shell script , how to do that? can we use .lock file or else any other best ways are there?

CodePudding user response:

.lock files are by convention used to identify running services and I would therefor vote against it. It just sounds like you want to keep track of your progress. If you do not mind the data being erased post reboot I'd suggest you simple use /tmp for that (this remains in memory), do mind that if we are talking very large amounts this will drain your available mem.

Without knowing your use case it's hard to tell you what is the best solution. But I would suggest writing an empty file that just indicates that your script is in progress(very similar to lock behaviour) and a second file that just keeps track of what items you processed. Then just loop over the items and skip until you hit a 'new' item. If we are talking very large amounts you should consider using a local database or database server.

  • Related