this works:
echo `date` echo `uptime` but is better this way:
echo $(date) echo $(uptime) (read about why here)
And, in this particular case, you'll probably be fine just with:
date uptime this:
cat /home/rpeb/example.sh 1> /home/rpeb/example.log will not execute your script.
cat /home/rpeb/example.sh is just printing the content of /home/rpeb/example.sh
and then, you are redirecting stdout from that command, to the file /home/rpeb/example.log. So, what your are really doing here, is making a copy of /home/rpeb/example.sh into /home/rpeb/example.log. Seems that this is not what youryou want.
But in case you do, this is more succinct:
cat /home/rpeb/example.sh > /home/rpeb/example.log when you just use >, the 1 before it is implied.
If you want to run the script /home/rpeb/example.sh, and then redirect its output to the file /home/rpeb/example.log, first, give execute permissions to /home/rpeb/example.sh, this way:
chmod u+x /home/rpeb/example.sh then, you run the script, simply writing its path, then redirecting its output, like this:
/home/rpeb/example.sh > /home/rpeb/example.log and, btw, if both files (your script, and your log to be) are in the same dir, and you are inside that dir, you con simply run:
./example.sh > example.log And if you want the output from example.sh printed on your terminal, and logged into example.log, you can do that this way:
./example.sh | tee example.log