You put the full path to top in the script but not the full path to grep.
When you run from command line the script inherits your environment including PATH so knows where to find binaries. When you run it from cron it has a minimal environment. You can solve that by any of the following methods:
1) Set the full path for each command in the command line. As noted above you did that for top but not for grep.
2) Set variables equal to the full path then use the variables instead of the command:
e.g.
Code:
export TOP=/usr/bin/top
export GREP=/bin/grep
...
$TOP -b -n 1 | $GREP -E "Cpu|Mem|Swap"
...
3) Explicitly set the PATH variable before calling any other commands:
Code:
export PATH=/bin:/usr/bin
...
Also verify "/bin/sh" in your first line is invoking the shell you intend. On many systems it is a link to bash but I've seen others where it is linked to something like dash.