Sysdate setting in .profile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sysdate setting in .profile
# 1  
Old 03-29-2010
Sysdate setting in .profile

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
Code:
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
# 2  
Old 03-29-2010
Why don't you use the command:
Code:
SYSDATE="$( date '+%d/%B/%Y/%S' )"

in your backup script to get the actual date?


Another way is an alias in your .profile:
Code:
alias SYSDATE=date '+%d/%B/%Y/%S'

# 3  
Old 03-29-2010
Quote:
Originally Posted by Franklin52
Why don't you use the command:
Code:
SYSDATE="$( date '+%d/%B/%Y/%S' )"

Code:
alias SYSDATE=date '+%d/%B/%Y/%S'

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
# 4  
Old 03-29-2010
Quote:
Originally Posted by malickhat
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
What is the problem to use an alias?
# 5  
Old 03-29-2010
Quote:
Originally Posted by Franklin52
What is the problem to use an alias?
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
# 6  
Old 03-29-2010
Sysdate setting in .profile

malickhat,

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.
# 7  
Old 03-30-2010
Quote:
Originally Posted by SteveR77
malickhat,

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
Code:
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
Code:
SYSDATE=`date +'%d.%B.%Y.%H:%M.%S'`
export SYSDATE

but it's not working i'm getting the same time every time ,i guess my situation is some what understand by you all
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Profile Max CPU Setting

I have a system with the following settings: min:0.10 Assigned: 2.0 Max: 6.0 Partition is uncapped weight is 128. I would like to know if even if this is uncapped, is the max it can use 6? The actual pool has 16. I remember reading about this somewhere but I don't remember can anyone... (3 Replies)
Discussion started by: techy1
3 Replies

2. UNIX for Dummies Questions & Answers

setting the profile

What's the purpose of setting the profile in side the script? however the user when logins, the profile wil be set. Then why we need to use that explicitly inside the script? Thanks (1 Reply)
Discussion started by: pandeesh
1 Replies

3. UNIX for Dummies Questions & Answers

Setting umask 022 by default to my profile

Hello everyone, I want to set my properties of my profile to umask 022 by default. I have an idea that i need to make the change in .profile file. Can you please help me, on how would i be able to set it. Thanks, Abhishek S. (4 Replies)
Discussion started by: abhisheksunkari
4 Replies

4. Shell Programming and Scripting

Need help in setting .profile , .cshrc , .exerc ..... in HP-UX , Solaris , AIX-UX

I need help in settings to Hp-UX , Solaris , AIX-UX .. I worked on Linux previously ... now i am working on Hp-UX , Solaris , AIX-UX .. up/down arrow , to see history of previous command (basically to modify ) and few keyboard keys are different ... so i need to set .profile , .cshrc , ... to... (1 Reply)
Discussion started by: girija
1 Replies

5. UNIX for Dummies Questions & Answers

setting home as lin in user profile

Hi. I have a directory structure built with links. For example: /home/user1 is a link to /var/123/user1 can i set the home variable in the .profile of the user to use a link? or it has to be a "real" directory? tks (1 Reply)
Discussion started by: mrodrig
1 Replies

6. UNIX for Dummies Questions & Answers

Setting up Bash profile

Hi, I have a SunOS -s 5.9 Generic_118558-39 sun4u sparc SUNW,Sun-Fire-V210 system. I need to set up my .bash_profile. I need to do the following thins. 1) set up history 2) Set up VI as my editor 3) Display the current directory at the prompt. I have tried using the set command, the... (1 Reply)
Discussion started by: kaushys
1 Replies

7. UNIX for Advanced & Expert Users

Setting Up Profile.......Need Help Urgently

Hi I am not able to setup PS1 environment variable in .profile file in my Home directory.I am using RED HAT3 Linux.this is the excercise that i have done $echo $SHELL /bin/ksh $pwd /home/khan $ls -l .profile -rwxrwxrwx $more .profile set -o vi export PS1='khan' $echo $PS1 $ (13 Replies)
Discussion started by: reachtokhan
13 Replies

8. Shell Programming and Scripting

NLS_LANG setting in .profile

Hi In my .Profile file initially I had given export NLS_LANG="BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1" and later I commented it. When I connect to sqlplus from shell prompt and query "select * from nls_session_parameters" it gives PARAMETER VALUE... (1 Reply)
Discussion started by: arksjd
1 Replies

9. UNIX for Dummies Questions & Answers

changed .profile but didnt ./.profile, yet reflected changes

hi , i added ls -F to .profile. and i need to do ./.profile for the effect to take effect BUT i didnt and YET the next day when i came to work and log in, the changes took effect. i am on aix. please explain.. thanks (4 Replies)
Discussion started by: yls177
4 Replies

10. UNIX for Dummies Questions & Answers

Setting LIBPATH in profile

Hi there, I wonder if anyone can help me. I run an application on an AIX 4.3.3 machine, for which I need to set up the LIBPATH environment variable for a specific user. I need this to be set up automatically when the user logs in (via Exceed), so I tried setting this in the .profile file. ... (7 Replies)
Discussion started by: durnelln
7 Replies
Login or Register to Ask a Question