Crontab command

Hello,

Could someone help me with crontab command form on AIX? :wall:

Thank you,

Yes.

Now in earnest: what exactly do you want to know?

My crystal ball is somewhat distorted today and i only see unclear pictures looking over your shoulder. You might as well enlighten me what your problem is and i will try to answer how to alleviate it. Deal?

I hope this helps.

bakunin

1 Like

@bakunin:
i have the following issue, i added a crontab command for some scripts :

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, the out file is empty so i can't see the error or the problem....

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 :

. /etc/profile.sas

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

/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:

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

next change your script this way:

# 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

Do you really have 6 time fields?
Should be 5, like this

07 08 * * 1-5 . /etc/profile.sas; /data/work/cr_folder1.sh > /data/work/cr_folder1.out  2>&1
2 Likes

Good catch! I have oveerseen that, my bad.

bakunin

1 Like

@bakunin : I tried your way and is working :slight_smile:
i'm thankful for your help

we have a new project to migrate from a solaris server to aix, and i'm trying to solve some issues that we have in the new migration.

have a nice day!

regards.
rimob