Search code examples
macoszsh

Using the at and batch utilities with zsh on MacOs


I am trying to schedule a one time job with the at utility. I am trying: at 13:00, then hitting enter, then <name_of_shell_script>, then ctrl+d.

The top line of my script is: #!/bin/zsh

but it is never executed. It executes when run manually, but not when scheduled with the at utility.


Solution

  • Since you're using , try using sched instead:

    1. Add to your .zshrc file:
      zmodload zsh/sched
      
    2. Restart your shell.
    3. Use it as follows:
      sched 13:00 <absolute path to shell script>
      

    See http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fsched-Module for more info.

    Also, make sure your script file is actually set as executable:

    chmod a+x <absolute path to shell script>