Sponsored Content
Top Forums Shell Programming and Scripting How to call .profile in cron? Post 91636 by grahamb on Sunday 4th of December 2005 09:11:30 AM
Old 12-04-2005
Including .profile: an example

Hi

Here is a line from my crontab:
Code:
10 4 * * * . ~/.profile; ${SCRIPTS}/backup_mysql.sh >> ${BACKUPS_LOG}/${HOSTNAME}_mysql_v${VERS}.script.log 2>&1

Assume each crontab command line generates a new shell. The ". ~/.profile;" command string: "dot space <...>", populates the environment variables for the new shell. The variables - in this case - are specific to the USER. They are called from the users home directory, etc.

The ". ~/.profile; " command string must be on the same crontab line, separated with ";" - a semi-colon. Do the same for EACH crontab command line.

Hope this is helpful!

Regards
GrahamB
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
crontab(1)						      General Commands Manual							crontab(1)

NAME
crontab - user job file scheduler SYNOPSIS
[file] [username] [username] [username] DESCRIPTION
The command manages a crontab file for the user. You can use a crontab file to schedule jobs that are executed automatically by (see cron(1M)) on a regular basis. The command has four forms: Create or replace your crontab file by copying the specified file, or standard input if file is omitted or is specified as file, into the crontab directory, The name of your crontab file in the crontab directory is the same as your effective user name. If the compartmentalization feature is enabled, the crontab file is your effective user name followed by a colon followed by the compartment id from which the crontab file is created. Edit a copy of the user's crontab file, or create an empty file to edit if the crontab file does not exist. When editing is complete, the file will be copied into the crontab directory as the user's crontab file. If the compartmentalization feature is enabled, it only edits a copy of the user's crontab file from the compartment that the crontab files were created from. Lists the user's crontab file. If the compartmentalization feature is enabled, it only lists the crontab files from the compartment that the crontab files were created from. Remove the user's crontab file from the crontab directory. If the compartmentalization feature is enabled, it only removes the crontab files from the compartment that the crontab files were created from. Only a privileged user can use username following the or options, to edit, list, or remove the crontab file of the specified user. The entries in a crontab file are lines of six fields each. The fields are separated by spaces or tabs. The lines have the following for- mat: minute hour monthday month weekday command The first five are integer patterns that specify when the sixth field, command, should be executed. They can have the following ranges of values: minute The minute of the hour, hour The hour of the day, monthday The day of the month, month The month of the year, weekday The day of the week, Each pattern can be either an asterisk meaning all legal values, or a list of elements separated by commas. An element is either a number in the ranges shown above, or two numbers in the range separated by a hyphen (meaning an inclusive range). Note that the specification of days can be made in two fields: monthday and weekday. If both are specified in an entry, they are cumulative. For example, runs command at midnight on the first and fifteenth of each month, as well as every Monday. To specify days in only one field, set the other field to asterisk For example, runs command only on Mondays. The sixth field, command (the balance of a line including blanks in a crontab file), is a string that is executed by the shell at the spec- ified times. A percent character in this field (unless escaped by a backslash is translated to a newline character, dividing the field into "lines". Only the first "line" (up to a or end-of-line) of the command field is executed by the shell. Any other "lines" are made available to the command as standard input. Blank lines and those whose first non-blank character is will be ignored. invokes the command from the user's directory with the POSIX shell, It runs in the queue (see queuedefs(4)). supplies a default environment for every shell, defining: Users who desire to have their executed must explicitly do so in the crontab entry or in a script called by the entry. You can execute if your name appears in the file If that file does not exist, you can use if your name does not appear in the file If only exists and is empty, all users can use If neither file exists, only the user can use The files consist of one user name per line. Security Restrictions If the compartmentalization feature is enabled, and invoke the jobs from the compartment that the jobs were created from. Note that cre- ates the job files in Hence, if the command is invoked from a compartment which has no write access to this directory and which disallows the privilege, fails to schedule the jobs. See compartments(5) and privileges(5) for more information. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text within file as single and/or multibyte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). determines the editor to be invoked when option is specified. The default editor is vi. International Code Set Support Single-byte and multibyte character code sets are supported. WARNINGS
Be sure to redirect the standard output and standard error from commands. If this is not done, any generated standard output or standard error is mailed to the user. FILES
Main cron directory List of allowed users List of denied users Accounting information Directory containing the crontab files SEE ALSO
sh(1), cron(1M), queuedefs(4), compartments(5), privileges(5). STANDARDS CONFORMANCE
crontab(1)
All times are GMT -4. The time now is 06:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy