Current Time & color label rule set not behaving as expected

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I've got a set of rules (and not sure if these can be consolidated into just one rule) that is intended to append a text file at 12:00 AM each day using an embedded shell script. The first rule will set the file's color label to red, then append it using the embedded shell script; once the time passes 12:01 AM, the second rule removes the color label so the appending rule will trigger again the following day.

I am trying to avoid the rule running repeatedly (and repeatedly appending the text file) while the time is still 12:00 AM.

The "red file label" technique in my rules slows down the repeated text appending, but does not eliminate it.

Image

Image

These two rules just repeatedly append the text file until the time is no longer 12:00 AM, and I can see the file in the Finder getting the red label on and off repeatedly during this time.

Here is the script code in case that makes any difference:

Code: Select all
DATE_PREPEND=$(date +"%Y-%m-%d")
echo -e "\n# $DATE_PREPEND" >> /Users/George/Dropbox/Notes/_journal.txt


My ultimate goal is for the text appending action to be run just once at 12:00 AM. If there is a less convoluted way to make this happen, I'm all for it. But I'm also curious why this setup isn't working.

Oh, and I am on Hazel 3 still since my attempts at upgrading to macOS didn't go well.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Note that Hazel shouldn't run the rule repeatedly so there's probably no need to do all this. Just set it up to do its thing at 12:00.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

When I initially set it up, I did just that. But ended up with hundreds of the text line appended to the document. That's the only reason I added the color label stuff.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

In general, the actions should not be re-run while the file keeps matching that rule. Also, keep in mind that Hazel has a 5 minute period after the actual time where it still might match in those cases where for whatever reason it doesn't get to it in time.

If you can dig up the logs around the time where it was constantly firing and email those in, I can take a look to see what's going on there.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

So here is the log from when it was repeatedly firing with the two-rule setup. I'll see if I can dig up the earlier logs, but I have a ton of unrelated errors which I need to look into as they clog up the log big time and make it tough to search.

Code: Select all
2016-12-21 00:01:11.461 hazelworker[91633] Processing folder Notes
2016-12-21 00:01:14.155 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:01:22.265 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:01:25.591 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:01:30.622 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:01:35.617 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:01:44.679 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:01:53.694 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:02:02.773 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:02:12.025 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:02:21.173 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:02:30.301 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:02:39.289 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:02:48.429 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:02:57.570 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:03:06.852 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:03:15.955 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:03:24.949 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:03:33.949 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:03:43.156 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:03:52.335 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:04:01.440 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.
2016-12-21 00:04:10.554 hazelworker[91633] _journal.txt: Rule insert today's date in _journal.txt & —>red matched.
2016-12-21 00:04:19.644 hazelworker[91633] _journal.txt: Rule _journal.txt —> no label matched.


I do have another rule which affects the color label for this file, but it should not be triggering — it should only fire on the 1st of each month.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

So as of last night, the 2-rule setup is now working as expected. I didn't change anything.

I'm going to use the single rule as you suggested and see what happens.
Last edited by gcoghill on Thu Dec 22, 2016 1:18 pm, edited 1 time in total.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

The logs will always show it matching. Depending on the actions you have set up, you may not see log messages for them unless you turn on debug logging. If you see the problem again, then turn on debug logging to get a more definitive view of what's going on.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I'm not entirely sure I follow, but those were the only log messages that related to that file or those rules.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

I simp,ivied this down to the single rule as suggested by Mr. Noodle and it seems to be working as expected now. Looks like I just ran into a temporary glitch. Which is relieving, because I was goi g a bit crazy trying to figure out why such a simple actions wasn't working as I expected it to.

Thanks again.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH


Return to Support