How to call .profile in cron?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call .profile in cron?
# 8  
Old 12-04-2005
Quote:
Originally Posted by mschwage
Also, I would caution against using $HOME/.profile in any shell script, in any event. This is because the $HOME/.profile is for setting up your login profile. When you are running a script you are not logged in. Your scripting environment should be stable, secure, and knowable. Since my .profile is mine, it's liable to be messed with at any time. Also, if you're doing such things as database backups or some system-related function with your ID- or depending on resources affiliated with your ID- what happens when you leave your job?
Mike's suggestion is spot on.
I should have made some clarification with my post.
The example I provided was a script/s being executed by an effectively non-interactive user-id and not your own.
Hope that makes some sence.
# 9  
Old 12-05-2005
HI,

I am lil bit confused here.... should we not use .profile in the script at all....I was in assumption that it is the safest way of doing it .....If we have our username and password in a script can't we use the variables defined in our .profile and use those variables in our script and run our .profile at starting of our script....I thought it is the best way...Is it not ...? please suggest if there is another way....

Thanks,

Girinath.
# 10  
Old 12-05-2005
As an alternative to relying on any .profile file is to create work specific environment files and have them executed.

For example.
Code:
#!/usr/bin/ksh
#
#- Ensure User Environment Set -#
. ${PATHNAME}/proofing.env
...
[rest of script]
...
#-End-of-script-#

The idea here is similar to the use of a .profile, however the principle is the same. The big difference is that the exporting of the variables and their values is not done on each login (using .profile) and are instead invoked only from the scripts that you wish to use the particular environment file.

An example of what an environment file might contain ...
Code:
AU_GMT_OFFSET='10'
NZ_GMT_OFFSET='12'
ACCOUNTS_EML_ADD='<some_email@domain.com>'
ADMIN_EML_ADD='<some_email@domain.com>'

It is these variables that are referenced in the script.
Hope that's of some help.
# 11  
Old 12-05-2005
I strongly discourage script to use the ${HOME}/.profile.
The ${HOME}/.profile is used for login and highly volatile to changes by users.

Imagine when you need to perform migration or the new application owner prefers to use a new shell or make changes to the .profile, unknowing it will impact the script.

Should always use a separate file for the script environment setting.
# 12  
Old 12-05-2005
True - something already discussed in this thread.
# 13  
Old 12-05-2005
See stty tcgetattr errors for another problem caused by .profile abuse.
# 14  
Old 12-05-2005
Thanks for the link/article Perderabo - good read.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Attemp to call the .profile

i have this line of code on my script #!/bin/sh #enable the environment variable thru profile . .profile when i run the script it was unable to find the .profile sh ChgPwd.sh ChgPwd.sh: line 4: .: .profile: file not found the file .profile exists ls -altr .profile... (2 Replies)
Discussion started by: wtolentino
2 Replies

2. Shell Programming and Scripting

How do i call aliases from my .profile?

Hello all, Please my shell is ksh. I created .profile such that users can pick environments they want to use: echo Select your Environment!! echo " 1. Nigeria DEV" echo " 2. UEMOA DEV" echo " 3. CEMOA DEV" echo "Make your choice : \c" read choice if then ... fi if then (6 Replies)
Discussion started by: mofaloks
6 Replies

3. AIX

Commands to call script work from command line but not from Cron entry

My first post evidently did not materialize so I posted it again: Runnning a cron job every 5 mins to send data files to a state facility. My original cron entry at worked fine: 01,06,11,16,21,26,31,36,41,46,51,56 * * * * /home/sftpuser/stateinoc-from-appname.ksh Somewhere I have a... (1 Reply)
Discussion started by: Skyybugg
1 Replies

4. UNIX for Advanced & Expert Users

Can we call crontab -e into .profile?

Hi All, I have a doubt that can we call under whatever scripts we mention in crontab -e into .profile . Because every weekend my server is going to restart so, my doubt whether crontab -e will automatically run my scripts or manually we have to save the crontab -e again? If that crontab... (3 Replies)
Discussion started by: ksrivani
3 Replies

5. Shell Programming and Scripting

Call .profile in perl script

Hello Gurus Can anyone please let me know how to call .profle file in perl script When I am calling the .profile file its giving error Shall I create unix script which has .profile command and call perl script internally (2 Replies)
Discussion started by: Pratik4891
2 Replies

6. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

7. Infrastructure Monitoring

trap in etc/profile and user .profile

Hello I really wonder what's trap in etc/profile and in each user .profile. I try to google for it but I think I have no luck. Mostly hit is SNMP traps which I think it is not the same thing. I want to know ... 1. What's a "trap 2 3" means and are there any other value I can set... (4 Replies)
Discussion started by: Smith
4 Replies

8. Shell Programming and Scripting

Please Help: How to Call SSH Trust from Cron job.

Hi All, I am tring to excute a SSH trust command from a script which is invoked by crontab. Details: Crontab file contains the following line: 15 00 * * * /users/dummy_user/dummy_script1.sh dummy_script1.sh contains the following line: SSH -1 server_2... (4 Replies)
Discussion started by: suman82
4 Replies

9. Solaris

cron .profile

The cronusers .profile doesn't seem to get call when running things in the cron. What am I doing wrong? (1 Reply)
Discussion started by: Schoey
1 Replies

10. 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
Login or Register to Ask a Question