- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Starting a process with cron
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
Forums
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
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
08-29-2001 11:44 AM
08-29-2001 11:44 AM
Starting a process with cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2001 11:55 AM
08-29-2001 11:55 AM
Re: Starting a process with cron
If so, why not just append the commands to the end of the backup script.
I do this with several processes that i run after my nightly backup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2001 11:57 AM
08-29-2001 11:57 AM
Re: Starting a process with cron
The environment supplied by 'cron' is very sparse. You can source your $HOME/.profile ahead of calling your script. This can be done in the crontab entry. Alternatively, you can source your profile within the script itself thereby providing the necessary environmental variables (including PATH). Thirdly, you could create a new file which contains and exports the common variables needed for your application, and source (read) that file within your standard profile; within standard scripts; and/or in a crontab stream.
To source (read) a file within a script, put a dot (".") in front of the script name. For instance, to source a file called 'myscript' you would do:
# . ./myscript #...note the space between the dot and the script name.
While you can source your $HOME/.profile, this generally leads to the annoying "not a typewriter" messages when commands like 'stty' are executed in a non-interactive environment. You could redirect stdout and stderr to /dev/null although you may miss important messages this way, or you could enhance your profile to execute these commands like this:
if [ -t 0 ]
then
stty...
fi
This leads full-circle to the idea of creating a file of environmental variables you need in a file that can be sourced independently of the profile and/or by the profile during login processing.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2001 12:00 PM
08-29-2001 12:00 PM
Re: Starting a process with cron
You can set your cron job for that user like this.
run "crontab -e" as that user. It will open the file for cron jobs already set by that user else it will open a new file in vi mode. You edit this file and define the schedule and comamnd to be run by cron in this file. The format will be
min hrs day_month month day_week command
so if want to set up a job to be run at say 11pm every night and the job file is /users/user1/cronjob.sh you have to put these values
00 23 * * * /users/user1/cronjob.sh 2>1&
save and exit. You don't have to specify the name of the file where you are saving. Just
The job is now set into cron. You can look at it by using
"crontab -l"
Read the man pages of crontab for more details.
Hope this helps
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2001 10:52 PM
08-29-2001 10:52 PM
Re: Starting a process with cron
The following command in the root crontab file will do what you need :
10 22 * * * /bin/su - UserName -c "/users/user1/bin/user1Script.sh arg1 arg2"
So, the script user1Script.sh will be running under the environment of user1.
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2001 10:55 PM
08-29-2001 10:55 PM
Re: Starting a process with cron
Oops, "UserName" stand for user1 in this case.
Magdi