Hi,
the application handles somethings and all users allowed to run the application should be able to change the date and time. So, when the file is created, the owner is one, but I need to update the date and time, according to some rules on the application, and the solution was to use the touch command.Note: everyone that is allowed to run the application, belongs to the same group.
user1 - group app1
user2 - group app1
The process:
user1 creates a file - xxx.txt, today - 20150109 10:10....
tomorrow, the user2 running the application, for example, he accesses the file xxx.txt by the application, so, for my control and my reason, I need to change the date and time. note: if the user1 tries to read the file xxx.txt, it works - the touch command, because the owner is the same.
today, the application issues the touch command with 2 parameters: the date/time and the folder+filename. (parameters: 201501100830 /xxx/yyy/zzz/xxx.txt), the final command is: touch -c -t 201501100830 /xxx/yyy/zzz/xxx.txt
If the solution is to run as root, I will need to do it. Of course, if there is other way to do it, and with safety, I would like to know,
One way to use your script, considering dynamic user, is the application read before the owner, and instead of use the touch command, it would be used your script with 3 parameters: the owner, the date/time and the folder+filename.
would it be a solution? on sudo statement in your script, would the password be requested? if so, it would be not the solution. I need to avoid any interactive session.
if I understood the idea of your script, the folder where the script will be stored, it will be always the same, but the folder and the filename where the date/time will be changed, not.
Please, let me know if it is clear and if there would be a solution for me.
tks.