title: How do I write a bash script that deletes my system log files after asking for permission at a certain time everyday?
body: <p>I want to write a bash script that deletes my system logs once a day at, say, 9PM Eastern Standard Time.</p>
  
  <p>I'm relatively inexperienced.</p>
  
  <pre><code>#!/bin/sh
  # I would want it to self-execute at some time every day.
  # Would that mean that the shell needs to always run in the background?
  # Is there a method by which I can add this execution to a daemon or other 
  # background-process's code-content? (If so please give me details)
  
  touch /Permission.txt            
  
  #^^Process creates a file in root directory
  
  chflags nouchg /Permission.txt
  
  #^^Just in case the "no changes" flag is on, preventing me from changing 
  #  permissions
  
  chmod 0747 /Permission.txt 
  
  #^^Sets permissions so that I can write to the file without being root.
  #  I also set group permissions to read-only, my logic being that I want
  #  raw data to go into this file without it being modified by shared  
  #  Ownership processes..? 
  
  echo "Delete System Logs for: "%d"/"%m"/"%y" ?"&gt;/Permission.txt
  open /Permission.txt
  Input=/Permission.txt&lt;/dev/f0
  
  #^^Not just for the purposes of this script but for future scripts-I want
  #  to capture raw binary data from peripheral devices. Is the output
  #  of the keyboard interpreted by the OS or any other process before saving
  #  to the text file?
  #  How do I get raw binary-output to a file from hardware devices? How can
  #  I go about understanding the opcode syntax-whether it uses even or odd
  #  parity; whether it is big or small endian; and other binary nuances. 
  
  while [ $Input != "Exit" ]
   do
    read /Permission.txt
     if [ $Input == "Yes"|"yes" ]; then
      echo "Exit"&gt;/Permission.txt
       echo "sudo rm -rf /private/var/log/* ;"&gt;ttys000     #See 1 below
        echo "********"                                  #The Password
         fi
     if [ $Input == "No"|"no" ]; then
      echo "Exit"&gt;/Permission.txt
       fi
  end
  #  1 not sure where the process is in the system and whether or not sending 
  #  that string to tty will result in the command being executed as if terminal
  #  were running, will the ";" be seen as the return button being pressed?
  </code></pre>
  
  <p>I want this to listen for the pattern "Yes" or "No" or its binary equivalent. How will the "read" command work in the while loop? How do I ensure that it reads for a certain pattern? Will the for loop function properly even after it enters "Exit" thereby closing the while loop, IE, will closing the parent process within the child process immediately interrupt the child process? </p>