Skip to main content

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
1 vote
1 answer
66 views

what's wrong with my cron command?

In my cron file (Mac, El Capitan) I have a line that simply updates a file name with a date every day. 0 1 * * * mv /Users/me/0backup* /Users/me/0backup_$(date +"\%m-\%d-\%y") This allows ...
user618's user avatar
  • 171
0 votes
0 answers
53 views

Why do I get a deadlock warning for a simple job on a cloud file?

I have a file that sits on a Cloud directory managed by a cloud storage service that uses the Apple FileProvider API. No, this is not iCloud, but this is apparently the same API framework in use. The ...
bjb's user avatar
  • 2,556
1 vote
0 answers
55 views

Cron and launchd rsync/ssh job do not work when screen is locked

I have implemented a bash script to perform a backup to a remote server over ssh using rsync. Running the script in the terminal works correctly. I then scheduled a crontab job to run this script ...
Alan M.'s user avatar
  • 11
0 votes
1 answer
88 views

why won't my cron command work?

I have manually added a command to my crontab file (Monterey 12.6.9). Pretty simple; the crontab entry is something like: 0 10 * * * mv /Users/me/Desktop/test /Users/me/Desktop/test2 Which means, at ...
user637's user avatar
  • 11
2 votes
0 answers
217 views

Add "Allow in the background" items from command line

Some of the applications on my system run only if they are allowed to run in the background. I want to run these apps only in certain time windows. Due to this, I am manually enabling the app in ...
Chillar Anand's user avatar
0 votes
0 answers
70 views

Python script unable to access external drive under cron

My desired cron job consists of a bash script that does the following: Create a new Python environment (with a new python executable) Use that Python executable to run a Python script, which accesses ...
Michael Jan's user avatar
2 votes
1 answer
112 views

What timezone is cron in?

If I run crontab -e and add a cronjob 4 5 * * * "echo hi", the job will run at 5:04 of what timezone? Let's say the laptop displays time in PST in the top menu bar and sudo systemsetup -...
Almenon's user avatar
  • 273
0 votes
0 answers
31 views

Task scheduled as a cronjob not executing [duplicate]

On my Macos 11.6.1, I want to execute a script 'task1.zsh' with the following content #!/bin/zsh /usr/bin/touch /Users/user/Documents/cronjobs/hello.txt echo hello >> /Users/user/Documents/...
ecjb's user avatar
  • 514
1 vote
1 answer
323 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 ...
R. C.'s user avatar
  • 11
0 votes
0 answers
1k 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 ...
Temperamental Duck's user avatar
1 vote
0 answers
142 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 ...
irishwristwatch's user avatar
1 vote
2 answers
163 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 ...
godawgs's user avatar
  • 11
0 votes
1 answer
547 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 ...
Dave's user avatar
  • 361
1 vote
1 answer
2k 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 &...
mariano-daniel's user avatar
0 votes
2 answers
325 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 ...
keith56's user avatar
  • 11
2 votes
3 answers
927 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....
CarriMegrabyan's user avatar
1 vote
1 answer
580 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 ...
JVC's user avatar
  • 2,871
0 votes
0 answers
149 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" -...
C. Ardayfio's user avatar
0 votes
1 answer
231 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 ...
mariano-daniel's user avatar
0 votes
0 answers
199 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 ...
mrbolichi's user avatar
  • 185
3 votes
1 answer
592 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 ...
Jacob Wegelin's user avatar
0 votes
2 answers
1k 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/...
Edward Falk's user avatar
  • 1,033
0 votes
1 answer
145 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/...
Infira's user avatar
  • 1
0 votes
1 answer
75 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 ...
Kokizzu's user avatar
  • 893
1 vote
1 answer
378 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 ...
Craig Edmonds's user avatar
3 votes
2 answers
12k 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'...
Alana Storm's user avatar
1 vote
1 answer
604 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 ...
tjcaul's user avatar
  • 266
4 votes
1 answer
2k 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". ...
dfried's user avatar
  • 143
1 vote
0 answers
185 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 ...
s1gtrap's user avatar
  • 11
1 vote
2 answers
703 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 * * * ...
Zane's user avatar
  • 11
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 ...
KS_on_StackExchange's user avatar
2 votes
2 answers
3k 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?
atreeon's user avatar
  • 518
2 votes
1 answer
2k 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. ...
figNewton's user avatar
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 ...
Michael Yoshpe's user avatar
0 votes
1 answer
317 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" --...
Tim Apple's user avatar
  • 109
1 vote
1 answer
376 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 ...
RobKohr's user avatar
  • 124
5 votes
3 answers
7k 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. ...
stevec's user avatar
  • 5,105
1 vote
1 answer
135 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 ...
Scottmeup's user avatar
  • 2,613
1 vote
2 answers
320 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:...
Virgula's user avatar
  • 123
2 votes
1 answer
938 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 ...
politicus's user avatar
  • 1,193
1 vote
2 answers
461 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 ...
Francisco Avalos Jr.'s user avatar
10 votes
2 answers
11k 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 ...
Yanick Nedderhoff's user avatar
0 votes
0 answers
147 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(...
dotdashdashdash's user avatar
1 vote
2 answers
4k 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 /...
Ben McIntyre's user avatar
0 votes
1 answer
91 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 ...
orange's user avatar
  • 269
0 votes
1 answer
107 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 ...
amrog's user avatar
  • 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 ...
Sybil's user avatar
  • 4,007
0 votes
0 answers
273 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 ...
Malooii's user avatar
60 votes
1 answer
31k 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/...
Tian's user avatar
  • 885
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 [email protected]:BAR Here ...
VoteyDisciple's user avatar