Bash script failing when run by cron - mktemp outputting nothing -
i have shell script, works when run manually, silently fails when run via cron. i've trimmed down minimal example:
#!/usr/bin/env bash echo "here:" echo $(mktemp tmp.xxxxxxxxxx) if run command line, outputs here: , new temporary filename.
but if run cron file this, here: followed empty line:
shell=/bin/bash home=/ mailto=”me@example.com” 0 5 * * * /home/phil/test.sh > /home/phil/cron.log what's difference? i've tried using /bin/mktemp, no change.
the problem script tries create temporary file in root directory when started cron , has no permission that.
the cron configuration file contains home=/. current directory / when script starts. , template passed mktemp contains file name mktemp tries create temporary file in current directory , /.
$ home=/ $ cd $ mktemp tmp.xxxxxxxxxx mktemp: failed create file via template ‘tmp.xxxxxxxxxx’: permission denied
Comments
Post a Comment