Is there a way (automator maybe?) or program to make an iMac record the microphone input on a scheduled time (start and finish). I need it like some kind of security webcam but for audio
This post explains something similar to what you are trying to do. I think that you can easily modify the workflow so it fits what you need starting from there.
Set up your workflow Launch Automator and in the New Template sheet that appears, select Service and click Choose. Build a workflow that contains these actions: New Audio Capture, Start Capture, and Stop Capture (all under Movies). In the Start Capture action enable the Wait For Capture To Complete option. In the Stop Capture action enable the Close Movie After Stopping option. Configure the top of the window to read Service Receives No Input in Any Application. Save your workflow and give it an intuitive name such as Voice Memo.
Voice memo window When you activate your workflow, the small Audio Recording window will appear. If you now click Automator’s Run button, QuickTime Player will launch, a new audio recording window will appear, and your Mac will start recording from the sound input device selected in the Sound system preference (from your iMac or MacBook’s microphone, for example). When you’re finished recording, just press the spacebar and your recording will be saved, the audio recording window will close, and you’ll find your voice memo saved as Audio Recording.mov in the Movies folder within your user folder. (Subsequent recording will be called Audio Recording followed by a number—Audio Recording 1.mov, for example.)