I have a simple script that checks for certain printers and records them to a file.
When I run the script manually at the command prompt, it works perfect, but when I run the script via cron, nothing happens. No errors reported, and no records are written out. I'm using Solaris 10. Below is the script:
#!/bin/ksh
DATE=`/usr/bin/date '+%d-%m-%y %T'`; export DATE
FILE=/usr/lbin/logs/disabled_printers.txt; export FILE
if a script executes from cli propperly and fails via cron it is ALWAYS the same old story.
check permissions and path variable.
test the following within your script
Thanks for the answer, you're right, if I put absolute paths for command it works . But, is there something I can do to make it work even if I dont specify absolute paths of commands? Like set something in the . profiles?
cron invokes the command from the user's HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.
depending on you unx u can set Path Variable in crontab
# Shell variable for cron
SHELL=/bin/bash
# PATH variable for cron
PATH=/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11 #M S T M W Befehl