Script not working on cron


#1

Hello,

I have a small script that runs fine from the terminal but it doesn’t seem to work when launched by the cron process.

I’m sure that cron is working because it updates my awstats periodically without problems.

This is my script:

/bin/ls -l /home/user/userdata/ | /usr/bin/cut -c30-35,49-100 | /bin/grep -e "[[:space:]]0[[:space:]]" | /usr/bin/mail email@domain.com -s "Checkfiles" -b logs@mydomain.com -e It emails the filenames that has no contents (file size = 0)

As you can see I added the full path to every command but it doesn’t seem to work.

The crontab:

0 0,7 * * * /bin/sh /home/user/userdata/check_files.sh > /home/user/cronlog.txt check_files.sh has permissions 777

Any idea?

Thanks in advance,
Jose


#2

Ok, I figure it out!

It seems that the output format of “ls -l” is different when is executed by crond, so the cut section was failing and therefore no email was being sent.

Thanks anyway,
Jose