- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cron - LANG variable being set causes child proces...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2012 02:15 PM
06-01-2012 02:15 PM
cron - LANG variable being set causes child process to be spawned
We were burned by some unexpected behaviour by the cron subsytem. We have a command that is being executed by the cron daemon using the at command. It appears that if the LANG variable is set, when the at command builds the script file that will be executed, at the top of the file it will add a line to export the LANG variable and then start a new shell process. For example:
my_script.sh:
export my_env="some value"
echo "my_env = $my_env"
if [ "true" = "true" ]; then
echo "Error - exiting"
exit 1
fi
echo "still running - now my_env = $my_env"
When the at command processes this file (at -f my_script.sh now) and builds the script that is put in the /var/spool/cron/atjobs directory it adds the following lines to the top:
export LANG; LANG=en_US.iso88591
/usr/bin/sh
....
The result is that because it is initiating this child shell process, when the condition evaluates to false it only exits out of the child process and continues on with the rest of the script (and any environment variables set while in the child process are now unset). So the output from the above script would look something like:
my_env = some value
Error -exiting
still running - now my _env =
I am assuming it is doing this because the LANG variable needs to be set before the shell is initiated to have an affect. The only way have found to prevent this is to unset the LANG variable before calling the at command. Is there a better way to control this? Does this behaviour indicate a configuration setup issue on the server? One thing I have noticed is that the LANG variable is when connecting to the server via remsh and not when signing in through telnet.
- Tags:
- AT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2012 02:37 PM - edited 06-01-2012 02:43 PM
06-01-2012 02:37 PM - edited 06-01-2012 02:43 PM
Re: at - LANG variable being set causes shell child process to be spawned
(This has nothing to do with cron, it's all done by at(1).)
>When the at command processes this file (at -f my_script.sh now) and builds the script that is put in the /var/spool/cron/atjobs directory it adds the following lines to the top:
export LANG; LANG=en_US.iso88591
/usr/bin/sh
There is nothing wrong with the export of LANG. The shell doesn't belong there.
at(1) takes a file of commands, not a script!
So you may have to use:
at ... <<EOF
my_script.sh
EOF
Looking closely at what you said, it appears you don't have that shell line in your my_script.sh?
If so, there may be something wrong with your /var/adm/cron/.proto?
What OS version are you using? There may be a patch for this?