I have a shell script that writes the date to a log file when executed. When I run the script manually, the correct output gets written to the file. However, this needs to be automated, and when I run as a cron job, nothing is getting written to the file and I am confused why.
crontab:
0 * * * * tomcat /usr/bin/sh /apps/rdsreplication/snap_replication.sh
Sample Code:
#/bin/bash/
echo ---------------------------------------- >> create_snap.txt
echo Start time: >> create_snap.txt
date >> create_snap.txt
Any help would be appreciated!
pwd
does cron run things under? – thrig Mar 02 '17 at 17:07/usr/bin/sh
? This is an unusual location for a shell. 2. Whichcrontab
file are you using, or how are you adding this line tocron
? 3. What gets reported incron
's log file (typically somewhere in/var/log
) for this job?which sh
, and that was the path returned. I am using the tomcat user's crontab, I am adding the line usingcrontab -e
./var/log/cron
shows this:Mar 1 18:06:01 sonar CROND[1585]: (tomcat) CMD (/usr/bin/sh /apps/rdsreplication/snap_replication.sh)
– AndG Mar 02 '17 at 17:13/bin
as a symlink to/usr/bin
nowadays, since it is no longer possible to have/usr
on a separate partition anyway. – Ulrich Schwarz Mar 02 '17 at 17:19NULL
on account of Active Directory doing lord knows what? Flapping between what LDAP is providing and a local account, depending on the whims ofsssd
or such? – thrig Mar 03 '17 at 15:30sssd
. In the configurations I use there's a template definition for users' home directories so it doesn't need to be specified in AD. However, regardless of how a user's home directory is set up, that's where thecron
instance sits. It's up to the user (or sysadmin) to decide whether or not the directory should be writeable. – Chris Davies Mar 03 '17 at 15:37