Questions tagged [cron]

Cron is a time-based job scheduler found in most Unix-like computer operating systems, like macOS. Cron is driven by a crontab (cron table) file, a configuration file that specifies commands to run periodically on a given schedule. This tag should be use when dealing with any cron issues.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Cron job keeps running unexpectedly. Works fine with current jobs, but repeats at other times

Super odd issue here. I have been using cron jobs for a few years and it has never given me any issues until now. Here is my cron job entries: #Start Kipros 54 8 * * 6 /Users/mediamac22/Desktop/...
  • 141
1 vote
1 answer
59 views

pmset wake ignores minutes settings

I am trying to schedule a Crontab job for, say, Monday at 12:59, even when my Mac is sleeping. To achieve this I use pmset repeat wake M 12:58:55 to wake up my Mac 5 seconds before the job. The first ...
  • 11
0 votes
0 answers
218 views

Cron job running while macbook lid is closed?

I have been using cron to run a script every morning at 5am daily (the script sends me an email with some data). In the past, I have always had to keep my laptop lid open and awake for the cron job to ...
1 vote
0 answers
81 views

create RAM disk as early in boot process as possible

I am attempting to to create a RAM disk as early as possible in the boot process so that my copy of Stata can use it to store temporary files. According to the instructions from Stata one can set the ...
1 vote
2 answers
97 views

Issue running command in cronjob but works as a regular command [duplicate]

I'm trying to run a yt-dlp command inside a cronjob but am having trouble. The command runs fine when run as a regular terminal command but inside a cronjob it fails. I've included an image of the ...
  • 11
0 votes
1 answer
131 views

How do I schedule a job to run every 15 minutes on Mac OS Big Sur?

I'm using Mac OS Big Sur. I want to run a script every 15 minutes, so I added this using "crontab -e" */15 * * * /bin/bash -l -c 'sh ~/Documents/my_script.sh' However, upon saving the ...
  • 569
1 vote
1 answer
358 views

Run script with crontab does not work

I know launchd is the way to go, but would really need to use cron in this situation. I'm trying to run the following command through cron: rclone copy /Users/x123/Downloads/torrents mega:torrents -q &...
0 votes
2 answers
124 views

"crontab -e" failing under Monterey with "$EDITOR: No such file or directory"

I was hoping for a little guidance with a problem that has me beaten. I want to use cronjobs on a Mac Mini running macOS Monterey, but it is not behaving as it does on other machines I have running ...
  • 11
0 votes
0 answers
159 views

Using a cron job script, how to tell if screen is locked?

I have a cron job running every hour which should do some things only if the screen is locked, and some things only if the screen is not locked. The cron job runs a bash script. I found this answer, ...
2 votes
3 answers
797 views

crontab doesn't seem to recognize `~`

Has anybody noticed that crontab doesnt seem to recognize ~ to mean the home directory? I tried using a full expansion of /Users/username/filename.txt in crontab, which worked, but using ~/filename....
1 vote
1 answer
231 views

How to renew DHCP lease via cron job?

I have a machine that reboots nightly, but when it does it ends up connecting to the wrong router somehow, and always gets the wrong IP. I don't want it to use a static IP, I have my router issue it ...
  • 2,633
0 votes
0 answers
100 views

FFMPEG image capture only executes partially on cron

I have the following shell script: DailyScript.sh #!/bin/sh now="/Users/mydir/Downloads/LIDOPRO/Captures/$(date +'%Y_%m_%d_%I_%M_%p').jpg" "/Users/mydir/Downloads/LIDOPRO/ffmpeg" -...
0 votes
1 answer
108 views

I need help translating this cron job into launchd

How do achieve the following cron job into launchd xml format?: * * * * * date > /Users/mariano/cron_test.log I've been trying in several ways, but I don't seem to be getting the ProgramArguments ...
0 votes
0 answers
106 views

Grant cron permission for Calendar access

A script in one of my cron jobs needs to access my Calendar, but in order to grant this permission I would need to add cron in the following list: As you can see from the window, I experimented a ...
0 votes
0 answers
147 views

Open GUI App after reboot with cron

I'm using Mac OS Catalina 10.15.7 and I'd like to open some apps after boot with a cron tab. I use the following cron tab: @reboot /bin/bash /Users/x/script.sh if I run the script, it works as I want ...
  • 175
3 votes
1 answer
316 views

under macos 10.15.7, why cannot cron find files on my external hard drive? [duplicate]

I purchased an external hard drive for scheduled backups of my macbook pro, presumably under cron. My rsync commands work fine when I invoke on the bash (interactive) command line. But as soon as I ...
0 votes
2 answers
636 views

Cron job can't access Documents - "Tar: Desktop: Couldn't visit directory: Unknown error: -1"

I have an automated backup script that runs from a cron job. It basically tars up my home directory and pipes it to a command that writes the tarball to Amazon S3. tar zcvf - -X BACKUP_EXCLUDE | /usr/...
0 votes
1 answer
122 views

Using tar on crontab causes it to use multiple processes which consume all cpu

The following line is the only line in crontab: * 13 * * * sh /Users/gentaliaru/Dropbox/work/scripts/backup.sh >/tmp/stdout.log 2>/tmp/stderr.log And the script contents are rm -rf /Volumes/X5/...
  • 1
0 votes
1 answer
37 views

AutoSync Time periodically

My Catalina weirdly have drifting time, sometimes 5 minutes, 10 minutes, 19 minutes (in 1-2 hours), today it's drifting 40 minutes (in 4 hours). Is there any brew package/daemon that automatically ...
  • 843
1 vote
1 answer
231 views

How to restart Mac Mail.app every night?

I want to restart my Mac Mail.app software every night at 6am (or any time I choose). What is the best way to do this? I DO NOT want to reboot my whole Mac every night, only the Mail.app. TIA. UPDATE ...
1 vote
2 answers
6k views

Run Shell Scripts on a Schedule

Is there "a right" way to run shell scripts on a schedule in modern versions of MacOS? My usual go to for this has been using the cron command -- but recent changes make seem like this isn'...
1 vote
1 answer
245 views

Where should I put cron jobs?

I have some shell code that I'd like to execute daily using cron. Currently, I have the entire code written as a one-liner, and the 6 variations (each designed to run at different times) are all ...
  • 256
3 votes
1 answer
645 views

Difference between wake, poweron, and wakeorpoweron on pmset

I'm trying to use pmset to wake my macbook before a cronjob is scheduled. The documentation says a scheduled event has a type that is "one of sleep, wake, poweron, shutdown, wakeorpoweron". ...
  • 33
1 vote
0 answers
116 views

Using launchd to run script once a day when logged in

I'm in the situation where I would like to run a script only once per day when I open my MacBook. I guess I could have the script note the date it was last run, and have it reject when run on the ...
  • 11
0 votes
2 answers
461 views

Why is Cron not running the enable wifi command?

I'm trying to use crontab to schedule the 'enable wifi' command: networksetup -setairportpower en0 on. I've been entering this command in the required format in the cron file, eg.: 05 15 * * * ...
  • 1
2 votes
0 answers
2k views

How do you turn on crontab logging on Big Sur?

I am running macOS Big Sur 11.2.1 and have several crontab jobs set up and they work fine, but I want to turn on the logging of all of my crontab jobs. I have read that with the recently releases such ...
1 vote
2 answers
1k views

launchd, how to run a command every 3 minutes, during working hours on a weekday?

I know cron and that is fairly simple */3 9-17 * * 1-5 myCommand How does one do the same in launchd?
  • 344
2 votes
1 answer
986 views

Write cron script to open and exit application

I'm trying to write a script that opens a brand new instance of safari, displays a webpage for 10 minutes, then quits safari. I think I can follow this Stack Exchange to do steps 1 & 2 of my goal. ...
1 vote
1 answer
2k views

crontab Operation not permitted - cron has full disk access

I have seen here various issues about the crontab 'Operation not permitted' issue for Mac OS, but I seem to have a more complex situation on my hands. I have a bash file on the desktop, which I wanna ...
0 votes
1 answer
266 views

Cron job cannot find ffprobe/avprobeor ffmpeg/avconv even though its installed

I have a cronjob setup to run "/Users/admin/Scripts/youtubedl.sh" Script: cd "/Users/admin/Music/youtubedl-music" /usr/local/bin/youtube-dl -o "%(title)s.%(ext)s" --...
1 vote
1 answer
265 views

"sudo crontab -e" not updating /etc/hosts

In my /etc/hosts file, I have records like this: 127.0.0.1 www.youtube.com To keep me from getting distracted. When I need something on one of the sites I have blocked, I add # to the beginning of ...
  • 124
3 votes
1 answer
2k views

How create a crontab on mac?

I'm trying to create a crontab on mac. I've tried crontab -e which takes me to what appears to be an empty file opened with vim. I make no changes and simply press esc, :, w, then q to save and exit. ...
  • 3,807
1 vote
1 answer
67 views

Running Cron with an updated Bash version

Is there a way to get cron to run with an updated version of Bash that's been installed? My OS came with Bash 3.x installed stock and I've upgraded it to 5.x with macports. When I query bash --version ...
  • 2,495
1 vote
2 answers
229 views

Cronjob macOS does not work if set with a bash external script

I'm trying to create a new cronjob which launches a script every time at startup. If I do cronjob -e and then I insert for example @reboot bash /Users/user/script.sh and then I save everything is fine:...
  • 123
2 votes
1 answer
597 views

Crontab -l command working. No other crontab command is working

New to crontab, I wanted to experiment. Running the command crontab -l gave me the following answer crontab: no crontab for User_1 Every time I tried to issue a command like 1 16 24 10 6 ping -D -c 1 ...
  • 1,123
1 vote
2 answers
352 views

cron queueing bash and python scripts

I'm currently looking to understand and get comfortable with crontab queues on my macbook pro. I recently solved an issue where my simple bash script would not execute. It turns out I had to move my ...
4 votes
2 answers
2k views

cronjobs do not run

I have recently switched from Ubuntu to MacOS. I tried to run the exact same cronjobs I ran on Ubuntu before, however they don't, and after trying to figure out if the crontab entries might have any ...
0 votes
0 answers
103 views

Granting cron permission to control Finder

I aim to use cron to call a python script that changes my desktop background. The key python line is as follows: from appscript import mactypes, app app('Finder').desktop_picture.set(mactypes.File(...
1 vote
1 answer
3k views

'Operation not permitted' accessing SMB Share as root under Catalina

I have a script that copies a file from our server to the local machine. Here is the script and output + date Thu Jun 11 09:16:00 ACST 2020 + id -un root + pwd /Volumes/Macintosh HD/backups + mkdir /...
0 votes
1 answer
82 views

Trying to add cronjob results in ""LICENSE":0: bad minute"

I am trying to set up a cronjob to run every minute with the following command: crontab * * * * * sh /Users/username/Downloads/reddit-notifications-master/notifyer.sh notifyer.sh has the following ...
  • 279
0 votes
1 answer
84 views

Issue with "date" command in MacOS Mojave

I think this is a "Full Disk Access" problem. I have added "Terminal" and "cron" to Full Disk Access. The problem is when I am trying to use the command below, it works from Terminal but not with ...
  • 121
1 vote
1 answer
2k views

how to automate / run 'brew cask upgrade' as a cron job?

I wish to run brew cask upgrade in a cronjob, but it prompts for a password. When I run the job as root all permissions are screwed up. Howto run that command in a cronjob env? I use zsh. ~ brew ...
  • 3,603
0 votes
0 answers
238 views

command silently failing when running from the root's crontab

I have a script that runs diskutil and since diskutil needs permissions to run I'm running the script from the root's crontab. Steps: sudo su root crontab -e sh /test.sh Nothing ever happens ...
42 votes
1 answer
21k views

Crontab Operation not permitted

I have the following crontab on my mac OS Catalina 10.15.1 : * * * * * /Users/username/Desktop/cronjob.sh > /Users/username/Desktop/cronjob.log 2>&1 Within the command file is: #!/bin/...
  • 675
6 votes
1 answer
3k views

rsync in cron on Catalina no longer working

I have various rsync entries in crontab that worked reliably right up until the moment I upgraded to Catalina. 00 04 * * * /usr/local/bin/rsync --archive /Volumes/FOO me@remote.example:BAR Here ...
3 votes
3 answers
4k views

cron lacks permissions to run a script

I have a script (which backs up, using rclone) that I can run from the Terminal or Automator after chmod a+x, with no permissions problems. However, when this script is run in cron (or launchd), ...
3 votes
1 answer
266 views

Launch app in foreground doesn't work from cron, but does from terminal

I have the following: * * * * * open -a /Applications/TextWrangler.app/ ~/notes.txt; open /Applications/Notes.app Neither of the 2 apps brings focus to the foreground (though they do get launched ...
8 votes
3 answers
2k views

"cron" processes spawning and piling up, but no crontab

EDIT: I solved this, so see below for my own answer. While the bounty asks for a fix to the problem, I'd like to award it to someone who can explain why a cron process that ran for 6 years over ...
  • 131
18 votes
1 answer
5k views

On Catalina, how can a cronjob get permission to touch files on a USB disk?

I have a USB disk, that takes ages to spin up after it has gone to sleep. So in the past I used either a cron job to regularly touch a file on it, so it will never spin down. */5 * * * * /usr/bin/...
  • 335
10 votes
3 answers
2k views

"cron" processes piling up

I have cronjobs doing various cleanup tasks: $ crontab -l 0 * * * * find ${HOME}/Downloads -depth 1 -d -mtime +12h -exec /usr/local/bin/trash {} \; * * * * * /usr/bin/defaults delete com.apple....