I have a small script that looks like this:
#!/bin/bash
ls -l
echo "end of listing"
echo 0 > this_script.sh
Basically, what it does is execute two commands and after it, it has to erase its own contents. I won't go into details regarding the reason I want this to happen because it's a long story (but might make a tutorial on this forum in case it works).
If I execute
Code: Select all
sh this_script.sh
This script must be executed with cron on a regular basis. Problem is, the last line (echo 0 > this_script.sh) will not get executed. Anything else will. I also double checked this reading the user's mail sent by cron: it displays the outputs proving that the script is executed.
So what is wrong with that redirect?