- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- crontab job and run on shell
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
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
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
тАО02-13-2007 12:45 PM
тАО02-13-2007 12:45 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2007 04:59 PM
тАО02-13-2007 04:59 PM
SolutionThe cron environment has nowhere near the PATH and other shell environment available to it.
So if you rely upon a shell-based environment variable or 'alias', these need to be put into the shell script you're running from cron.
Also note, that you *MUST HAVE* the hash-bang ('#!/bin/bash') at the start (along with executable permissions), otherwise cron won't know how it executes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2007 07:43 PM
тАО02-13-2007 07:43 PM
Re: crontab job and run on shell
I still have a bit misunderstand , do you mean I need to add ('#!/bin/bash') at the beginning of my script ? if not that , can advise what I need to do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2007 12:21 AM
тАО02-14-2007 12:21 AM
Re: crontab job and run on shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2007 07:08 AM
тАО02-14-2007 07:08 AM
Re: crontab job and run on shell
also please add the path of the command to the PATH environment variable. Like PATH=$PATH:/usr/lcoal/bin
or use full path for all the commands in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2007 07:15 AM
тАО02-14-2007 07:15 AM
Re: crontab job and run on shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2007 09:45 AM
тАО02-14-2007 09:45 AM
Re: crontab job and run on shell
As noted, the environment in which a 'crontask' runs is sparse. Instead of adding the environmental variables you commonly need (e.g. PATH, etc.) to every script that you 'cron', source (read) a file that you define specifically to hold environmental variables.
Thus, your scripts would begin something like this:
# cat ./myscript
#!/bin/bash
. /home/hangyu/config
echo "hello ${WHO}"
exit 0
# cat ./config
WHO=Hangyu
Then run:
# ./myscript
...Now you have defined *one* configuation file that you can modify for *all* your scripts' needs.
Regards!
...JRF...