Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switching Shells in CRON Job

Status
Not open for further replies.

cptk

Technical User
Mar 18, 2003
305
US
I can successfully execute a cron job that executes a script file that includes the shbang line #!/bin/ksh, but if instead I put all my commands within the cron job, I can't seem to switch from the sh (default shell) to ksh. What cmds do I need to add to the beginning of the cronjob? Something like ...
"set SHELL=/bin/ksh;" or "export $SHELL;" ... I can't seem to get the right combination!
 
/bin/ksh -c 'here are my ksh commands'

(when in doubt, 'man ksh')

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks vgersh99 !!

Using vgersh99's suggestion, plus exporting and setting display all in one cmd, works great:

/bin/ksh -c 'export DISPLAY=12.34.567.89:0.0; /somedir/exec'

I would of thought this variation would of worked:

/bin/ksh -c 'DISPLAY=12.34.567.89:0.0; export $DISPLAY; /somedir/exec'

It gives error: /bin/ksh: 12.34.567.89:0.0 is not an identifier

Why?
 
either:

/bin/ksh -c 'DISPLAY=12.34.567.89:0.0; export DISPLAY; /somedir/exec'

or

/bin/ksh -c 'export DISPLAY=12.34.567.89:0.0; /somedir/exec'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
ooopps ... leave out the $ in the export -- dah!
Sorry ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top