Views:
6,805
Votes: 1
✅ Solution
Tags:
scripts
cron
Link:
🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
URL:
https://askubuntu.com/q/1188181
Title:
Output redirection to a file, used inside script, is not working when executed from crontab
ID:
/2019/11/12/Output-redirection-to-a-file_-used-inside-script_-is-not-working-when-executed-from-crontab
Created:
November 12, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
logs/testpad1.log
will behave differently depending on your current directory. It can also behave differently depending if cron
is running as root or you are calling the script from your terminal.
The safe (and usually error correcting) thing to do is hard code the full path into the file name:
/home/me/scripts/logs/testpad1.log
/var/log/testpad1.log