Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running a cron job without rerading the .profile

Status
Not open for further replies.

mrberry

MIS
Jun 15, 2004
80
US
Does anyone know if there is a way to run a cron job without the users .profile being read? The users .profile has a an interactive menu and when a job is run through cron in never completes because it is waiting for user input.

Thanks
 
If the cron job is a script and it has a shebang line, you probably need to add a -p to the invocation:

#!/bin/bash -p

If that doesn't fix it, then you need to wrap the interactive lines in some conditional. For my bash login files I use:

Code:
case $* in
    *i*) stty erase
         # interactive commands go here
        ;;
esac
 
Hi mrberry,

I am curious to know which flavour of UNIX you are using because I have just checked the man pages (man crontab) on Tru64 UNIX and Solaris 8 and both say that the users .profile is not executed from cron. [Hence the number of recent posts from people wondering why PATH and other environmental variables are not set up as they want when running scripts from cron].

If this is the case you may want to re-investigate the reason(s) why your cron job never completes.

I hope that helps.

Mike
 
I can confirm that I've checked AIX and it also doesn't read the .profile for cron jobs

Columb Healy
Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
 
The OS is AIX 5.2. I took a users word he was unable to run a cron job because of his interactive .profile and was researching a way to prevent reading of the .profile. I will have to investigate more closely what he is doing.

Thanks for the replies.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top