Hi,
I need to append the current system date and time in my file which are being taken a backup by my shell script .so i added the following line in by .profile
SYSDATE="$( date '+%d/%B/%Y/%S' )"
export SYSDATE
But it's a constant one rather then a sync with my system date ,so how can i do that in my .profile file
My Requiremnet is such a way that i have to use the .profile to put all my shell script varialble like sysdate , directory path and all that . so both you're above options are not helping me here
This is the real realson,My project is such a way is that i have to do in this way if i go with you're work around i won't get my project completed .i really don't know how to explain my situation.Please understand
There is an issue if you are wishing the sysdate variable to be dynamic.
The .profile will only be executed once when the user in question logs in so the value it will hold as you have already stated will be static or a constant.
The only way that you could force it to be dynamic would be to perform the execution of the .profile every time you wished to get your date time stamp.
This would potentially create a lot of overhead because in effect you would be resetting the environment every time you needed to get an updated date value.
The catch here is it appears that the goal is counter to what you are actually attempting to accomplish.
If you could please try to explain what it is you are attempting to accomplish once more. I understand that it may not be easy to do but it may provide what I am missing in order to try to help you find a solution that will meet the demands of your project.
My Problem is ,i have one script wich takes a back of xyz file in /home to /backup dir.this backup is scheduled for daily process ,what i want to make is that in that script the copy line
cp /home/xyz /backup/xyz.$SYSDATE
the $SYSDATE here i've to get is from the time of execution(current time).
so i thought of putting this line in my .profile
If that backup is taken daily, it's probably automated by cron. And if this is true, then it doesn't matter anyways what you set in your .profile, as that isn't read by cron.
The script doesn't take only one file for backup,it has many files inside my backupdir ,so just want to know how to append the $SYSDATE in that backupfile.And my cron only calls a parent script which intrun calls the child script which takes backup.
In general i have seen so many files which are apended by the date which its is created ,so guys please give me some tips .