I have a crontab as below:
PATH=/usr/local/sbin:/bin/:..... etc etc
0 8 * * * /home/user/jobs/poll.sh 2>/dev/null 1>/dev/null
Now the script poll.sh is called at correct time and executes.
This is how poll.sh looks like
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games .... BIG path
# Just load required envn variables
. ~user/.envvariables
# Now execute a perl program and email me the output ...
VAL=$(~users/jobs/fetchNprocess.pl 2>/dev/null)
echo $VAL | mail -s "Processed data for today: `date`" dummy@newsasnow.com 2>/dev/null 1>/dev/null
#### Here are some method already tried
#### Just do everything in one line
# ~users/jobs/fetchNprocess.pl 2>/dev/null | mail -s "Processed data for today: `date`" dummy@newsasnow.com 2>/dev/null 1>/dev/null
### Process and send as body
# mail -s "Processed data for today: `date`" dummy@newsasnow.com < `echo $VAL` 2>/dev/null 1>/dev/null
the output of the perl program (fetchNprocess.pl) is as below(when I run manually not cron):
Processing DATA for 1: 123324534 213w1312 asdasd [DONE]
Processing DATA for 2: 123324534 213w1312 asdasd [DONE]
Processing DATA for 3: 123324534 213w1312 asdasd [DONE]
Processing DATA for 4: 123324534 213w1312 asdasd [DONE]
Processing DATA for 5: 123324534 213w1312 asdasd [DONE]
5
The output contains many lines also empty lines The output I get after cron runs in only first line in my email.
Processing DATA for 1: 123324534 213w1312 asdasd [DONE]
It does not process all the lines ...
When I run the same program manually it works fine.
As far as crontab goes I took care of path and right env variables.
Any suggestion what could have cause the perl program to do only one iteration.
Other details of the server
Ubuntu 9.10
Linux 2.6.37-server #1 SMP i686 GNU/Linux
perl, v5.10.0 built for i486-linux-gnu-thread-multi
GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu)