Using Crontab

Hi All,

I've a shell script which calls a Sybase stored procedure to do some functionality. I want to schedule the running of this script by crontab. I'm using Solaris 5.8. When i executed the following command

crontab -l

i got the output as

crontab: can't open your crontab file

How can i schedule the script. I'm not the administrator. How can i unschedule it later as this script is a sample script.

Thanks in advance
Sumesh

That means that you do not yet have a crontab.

crontab -e

to edit (and thus create) it.

To view syntax on the crontab command, and the crontab file itself (as well as cron facility access controls, etc)...

man crontab

If you want to unschedule your job, either crontab -e, then remove the line containing the job completely, or just comment it out. Else; if that's the only job in your crontab, crontab -r to delete the crontab entirely.

Cheers
ZB

ZB,
Thanks for the reply.

I created the crontab file and my file looks like

47,3,19,2,1 /home/dsdev/bdayfinder.sh

I want the aforesaid script to get executed at the specified time, but i get the error like

crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.

I've checked the file thoroughly and couldn't trace the problem.

Pls help me out.

Sumesh

Did you read the man page?
The syntax of your line isn't correct, the 5 time and date fields must be seperated by spaces or tabs.

Regards

Thanks for the reply.

I used the correct synatx and now my crontab file is

50 1 20 2 * /home/dsdev/bdayfinder.sh

But, the script specified above is not getting executed.

I checked the /usr/lib/cron directory. There is no cron.allow file and the username dsdev which i use is not present in cron.deny as well.

I edited the crntab file and included the above mentioned line, saved and came out of the editor. The script which is expected to be triggered at 1:50 is not getting triggered at that time.

Pls let me know what has gone wrong?

Thanks,
Sumesh

Check your mails for error messages from crn dealon.

Jean-Pierre.

The script which i try to get scheduled is having isql command in it. The crontab file is set as follows.

* * * * * cd; script.sh > /tmp/result 2>&1

the file result in /tmp directory shows

isql: not found

I came to know that the isql is not set in the PATH environment variable.

Presently the PATH environment variable in my .profile file is

export PATH=$SYBASE_OCS/bin:$DSHOME/bin:$ORACLE_HOME/bin:/usr/local/bin/:/usr/ccs/bin:/usr/local/SUNWspro/bin:$PATH

Will including isql into this will solve the problem. If so, how can i modify it.

Thanks,
Sumesh

cron doesn't execute the .profile
a possible solution is to set the environnement before executing your script

* * * * * cd; . ./.profile; script.sh > /tmp/result 2>&1

jean-Pierre.

The best way is to define PATH within your script.

I always circumvent these kinds of issues by always specifying paths to executables in my scripts thus:

FOO="/usr/bin/foo"
${FOO} -options > myfile

Search the forums - this comes up time and time again....

Cheers
ZB

Sorry ZB. Can u explain what u r doing by this code?

I am defining the paths to each executable I use, and then using them as appropriate within the code - that way I do not need to worry about PATH as I'm explicitly defining the absolute path to each executable.

Here is a more practical example.

Cheers
ZB