Sponsored Content
Full Discussion: Crontab command
Operating Systems AIX Crontab command Post 302977439 by bakunin on Monday 18th of July 2016 07:38:40 AM
Old 07-18-2016
Quote:
Originally Posted by rimob
Code:
07 08 * * * 1-5 . /etc/profile.sas && /data/work/cr_folder1.sh > /data/work/cr_folder1.out  2>&1

but the command is not working
That is understandable. You try to set an environment, but you start two separate environments for this. In one of them you source in the file /etc/profile.sas:

Code:
. /etc/profile.sas

If this command returns "TRUE" (or 0, which is, for this purpose, the same), then in a second environement the command

Code:
/data/work/cr_folder1.sh > /data/work/cr_folder1.out  2>&1

is executed. But perhaps you rely on a certain environment to be set inside your script, not in some other unrelated process. This is why your script (most probably) failed.

Note that this is all conjecture because i cannot read what in the script /data/work/cr_folder1.sh is (crystal ball not working, y'know).

If my educated guesswork is indeed right you might want to do it this way:

First, change your CRON entry to:

Code:
07 08 * * * 1-5 /data/work/cr_folder1.sh > /data/work/cr_folder1.out  2>&1

next change your script this way:

Code:
# cat /data/work/cr_folder1.sh
#! /bin/ksh

if [ ! -r /etc/profile.sas ] ; then
     print -u2 "Environment file /etc/profile.sas not found. Aborting."
     exit 1
else
     . /etc/profile.sas
fi

<... rest of your script ...>

exit 0

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Having Problem with crontab command

Hi all , When i am tryting to execute crontab from home directory for a shell script which is located in some directory it is giving a error message The crontab file is 0 9-17 * * 1-5 /mydir/myshell The following output is given Your "cron" job /mydir/myshell produced the following... (1 Reply)
Discussion started by: arunava_maity
1 Replies

2. UNIX for Advanced & Expert Users

crontab command not working

Dear Friends, I have tried to fire a job on daily basis through crontab command but it willn't work. i have given in the following manner: 07 19 * * * exp /user_name/passwd/ file = /path/file-name full = N owner = user-name but it is giving error that permission denied. i have checked that... (8 Replies)
Discussion started by: digant
8 Replies

3. UNIX for Dummies Questions & Answers

getting the date in crontab command

Hi All, There is a requirement to create a file everyday using the cronjob with the date as its name. any suggestions for the crontab command that'll serve this purpose? e.g. 02 30 * * * touch abcd.`date +%d.%m.%y` needless to say.. this doesn't work.. looking fwd to lots of... (7 Replies)
Discussion started by: pranavagarwal
7 Replies

4. Shell Programming and Scripting

crontab + exec command

hi I am trying to activate auto_run.sh from crontab using following command line but nothing happen. 35 11 * * * -exec /u/uniacc/auto_run.sh and this is the first line of auto_run.sh ksh exec auto_inv.4ge > kti (4 Replies)
Discussion started by: naushad
4 Replies

5. Shell Programming and Scripting

command faster in crontab..

Hi all you enlightened unix people, I've been trying to execute a perl script that contains the following line within backticks: `grep -f patternfile.txt otherfile.txt`;It takes normally 2 minutes to execute this command from the bash shell by hand. I noticed that when i run this command... (2 Replies)
Discussion started by: silverlocket
2 Replies

6. Shell Programming and Scripting

crontab doesn't allow `command` ??

Dear All, We wrote a script to clean email mailbox when they're nearly full and put it in cron : 0 0 * * * /root/quota/autoclean.sh > /root/quota/autoclean.`date '+%Y%m%d'` 2>&1 I've run this command from command prompt, it did work. However, if running from cron, it returned such error... (1 Reply)
Discussion started by: tiger2000
1 Replies

7. Shell Programming and Scripting

date command issue from crontab

Hello Experts, I am facing problem in date command with TZ test.sh Output : 26-May-2010 27-May-2010 I scheduled this script everyday at 1 a.m 00 01 * * * sh test.sh when i was called this script test.sh from crontab , it was giving me other output (1 Reply)
Discussion started by: pritish.sas
1 Replies

8. Shell Programming and Scripting

date command issue from crontab

Hi Expert, I am using TZ for extracting yesterday date and day before yesterday date example : date_yes=`TZ="GMT+28" date +'%d-%b-%Y'` date_dbyes=`TZ="GMT+48" date +'%d-%b-%Y'` echo $date_yes $date_dbyes 26-May-2010 27-May-2010 I have written a small script for the same named... (1 Reply)
Discussion started by: pritish.sas
1 Replies

9. HP-UX

rcp command is not working in crontab

Dear Friends, I am trying to copy SAP log file from one HPux server1 to another HPux server2 remotely through one script. following command has written in the script. rcp -rp /oracle/PRD/sapreorg/*.dbf oraprd@drsite:/oracle/PRD/sapreorg Above command working fine from command mode.... (5 Replies)
Discussion started by: BPANDEY
5 Replies

10. UNIX for Dummies Questions & Answers

Crontab command help

Hi All, I want a script to run every 5 minutes and in the command prompt i typed the following command $ */5 * * * * /u01/EnvironmentStartup/validateservices.sh and when i enter i'm getting a message "-bash */5: No such file or directory" Any ideas please? Thanks Please wrap all code,... (6 Replies)
Discussion started by: thinkingeye
6 Replies
CRONTAB(1)						    BSD General Commands Manual 						CRONTAB(1)

NAME
crontab -- maintain crontab files for individual users (ISC Cron V4.1) SYNOPSIS
crontab [-u user] crontab [-elr] DESCRIPTION
crontab is the program used to install, deinstall, or list the tables used to drive the cron(8) daemon in ISC Cron. Each user can have their own crontab, and though these are files in /var/cron, they are not intended to be edited directly. If the /var/cron/allow file exists, then you must be listed therein in order to be allowed to use this command. If the /var/cron/allow file does not exist but the /var/cron/deny file does exist, then you must not be listed in the /var/cron/deny file in order to use this command. If neither of these files exists, depending on the compiled in settings, only the super user will be allowed to use this command, or everyone will be allowed to use this command. On NetBSD everyone is allowed to use this command. The default maximum size for a crontab is 256 kilobytes, but this may be changed for all users on the system by putting the desired maximum size (in bytes) in the /var/cron/maxtabsize file. If the -u option is given, it specifies the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines ``your'' crontab, i.e., the crontab of the person executing the command. Note that su(1) can confuse crontab and that if you are running inside of su(1) you should always use the -u option for safety's sake. The first form of this command is used to install a new crontab from some named file or standard input if the pseudo-filename ``-'' is given. The -l option causes the current crontab to be displayed on standard output. The -r option causes the current crontab to be removed. The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically. FILES
/var/cron/allow Optional list of users that are allowed to use crontab. /var/cron/deny Optional list of users that are disallowed to use crontab. /var/cron/maxtabsize Maximum size of crontab files. Defaults to 256 kilobytes. /var/cron/tabs/ Directory containing the individual user crontab files, named after the user. DIAGNOSTICS
A fairly informative usage message appears if you run it with a bad command line. SEE ALSO
crontab(5), cron(8) STANDARDS
The crontab command conforms to IEEE Std 1003.2 (``POSIX.2''). This new command syntax differs from previous versions of Vixie Cron, as well as from the classic Version 3 AT&T UNIX syntax. AUTHORS
Paul Vixie <vixie@isc.org> BSD
May 6, 2010 BSD
All times are GMT -4. The time now is 05:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy