Reputation: 4615
probably an easy question, but I am confused:
When I run the following script manually, it works fine. While I am not running this script as user git but as user X I am able to use the ls and du commands which are applied to git users home directory. If I try to run this script in a cronjob, these two commands are not regular invoked, don't know why. The first "extern" invocation of a cmd-file works perfect in both cases and yields a regular output.
What I've noticed: I am just able to run the script as user X with ./runbackup.sh and it is stored in the users home directory.
Cron runs with user X's privileges.
Confusing ... :/ ... any ideas ?
Script: runbackup.sh:
#!/bin/bash
/cygdrive/e/xp-batches/backup.cmd > info.log
echo "### CURRENT HOMEDIR ###" >> info.log
ls -gh --block-size=K /home/git >> info.log
echo "### SIZE ###" >> info.log
du -hs /home/git >> info.log
email -s "Backup Status" [email protected] < info.log
Upvotes: 0
Views: 184
Reputation: 40810
Better not assume anything about the environment that cron supplies you with. Use full paths:
/bin/ls -gh --block-size=K /home/git >> info.log
instead of just "ls".
Oh and maybe use an absolute path instead of info.log as well.
Upvotes: 1