Running a bashscript from screen

Ultraf

New Member
Credits
0
Hello, I'm trying to run a bashscript from screen, but it does not work correctly, the file is never started with screen, command gets inserted into the .sh file.

Bash:
#!/bin/bash
while true
do
./file > ./logs/output.log
done;
What am I doing wrong?
 


Rob

Administrator
Staff member
Credits
74
i'm not sure, but since you're running a separate bash script within screen, is it spawning a new session? I don't think i've ever run into this.. you're saying you'll start a screen session, run this.. and after you ctrl-a-d out, then screen -r back in, it's not there?

What happens if you just do the while loop typing it out w/o running a separate script for it? same results?
 

JasKinasis

Well-Known Member
Credits
1,193
One other observation - you're running your script called "file" in an infinite loop and you're redirecting output to a file using > which will effectively overwrite the output file from scratch each time the script is ran.

I haven't got time to try something similar - but I'm not sure you'd ever see any output in that file, because as soon as there is some output in it - it's completely overwritten with the data from the next run.
What happens if you redirect using >> ?
That should cause your script to append to the end of the file instead of re-writing it from scratch.
But be careful - because depending on the amount of output written to the file on each run - you could end up with a massive log-file in no time at all!
 
  • Like
Reactions: Rob



Top