odd-even weeks or calculating fortnights
Dec. 7th, 2017 01:03 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
This calculates even weeks, that is, it can calculate fortnights:
expr \( `date +%s` / 604800 \) % 2 >/dev/null || echo "even"
or if you want odd weeks:
expr \( `date +%s` / 604800 + 1 \) % 2 >/dev/null || echo "odd"
There are 604800 seconds in a week.
"% 2" gives the remainder after division by 2.
When expr evaluates to zero the command after the OR (||) is run.
My rubbish collection is on alternate weeks. But cron doesn't know about fortnights and I only put my rubbish out once every two or three months (I don't have much waste). So I use this in cron to trigger an alert on the appropriate day:
0 10 * * mon expr \( `date +\%s` / 604800 + 1 \) \% 2 > /dev/null || alert "garbage day"
I can't remember why I escaped the "%" symbols. I think maybe cron chokes on them if you don't.
Oh, I should add that "alert" is not a standard command. It is a script that I wrote which puts a notice on the screen and uses speech synthesis to announce the message.
expr \( `date +%s` / 604800 \) % 2 >/dev/null || echo "even"
or if you want odd weeks:
expr \( `date +%s` / 604800 + 1 \) % 2 >/dev/null || echo "odd"
There are 604800 seconds in a week.
"% 2" gives the remainder after division by 2.
When expr evaluates to zero the command after the OR (||) is run.
My rubbish collection is on alternate weeks. But cron doesn't know about fortnights and I only put my rubbish out once every two or three months (I don't have much waste). So I use this in cron to trigger an alert on the appropriate day:
0 10 * * mon expr \( `date +\%s` / 604800 + 1 \) \% 2 > /dev/null || alert "garbage day"
I can't remember why I escaped the "%" symbols. I think maybe cron chokes on them if you don't.
Oh, I should add that "alert" is not a standard command. It is a script that I wrote which puts a notice on the screen and uses speech synthesis to announce the message.
no subject
Date: 2017-12-09 11:24 am (UTC)I am impressed it is that infrequently. Broadly, the two of us create about 1.5 bags of rubbish a week (the Glad bags, so about half a dark green traditional bag), and if it weren't for the cat litter and waste cat food (and maggots) I'm not sure we could still swing that. (And that's not including the green waste and recycling bins - although I swap the bins about physically as a reminder).
I know I have completely avoided your cron job comment, but hey...
no subject
Date: 2017-12-09 12:43 pm (UTC)My recycling bin tends to go out about once every 4 or 5 months. I hate discarding stuff. I save all the milk bottles, cutting some of them up as containers for various things: pots to grow plants in, trays to hold things, and two -- one inverted over the other -- hold things like dog food and other stuff. The cut-off tops become scoops or funnels (though most of those sadly go into the recycling.
I hope to do some experiments in melting and re-purposing the polyethylene they're made from. It is a wonderful kind of plastic -- extremely durable, non-toxic, light, with a very low-friction surface. To do that though, I need a way to ensure I can control and regulate the solar furnace I'm intending to use. There is a narrow range between melting the plastic and burning it. I haven't solved that yet.
Many of the milk bottles will have a second life filled with water in a pair of heat-exchange chambers as part of the small underground house (really just a room) I intend to build for myself next year. Letting convective air move through such compartments will keep the room at a stable temperature regardless of the weather outside -- and at zero energy cost. Water has an astonishingly high thermal mass. And the plastic, protected from the sun, will greatly outlast me -- it could last thousands of years. (I wish I could too.)
no subject
Date: 2017-12-09 12:59 pm (UTC)I need a way to ensure I can control and regulate the solar furnace I'm intending to use. There is a narrow range between melting the plastic and burning it. I haven't solved that yet.
I'm actually impressed. (As in, not just saying I'm impressed, but the next level).
My understanding is that the hydrocarbon chains in plastic are such that you won't get anywhere with repurposing (although, if you could, fertilisers might be worthwhile), because my science is high school level and pop-sci, but I don't know enough to say it can't work.
Letting convective air move through such compartments will keep the room at a stable temperature regardless of the weather outside -- and at zero energy cost.
I'd not have thought (plastic) milk bottles would be strong enough. But good luck.
no subject
Date: 2017-12-09 08:06 pm (UTC)I would like chickens, but Julie won't allow it. Being far out in the country we have rodents anyway.
"Solar furnace" sounds impressive, but it's not. I simply have a fresnel lens that I'm clumsily experimenting with on small pieces. Here are a couple of examples of the power of the sun reaching more than 3,000°C:
https://www.youtube.com/watch?v=svAPyyUJUCo
https://www.youtube.com/watch?v=drE54ctrHBY
My fresnel lens is much smaller and I don't need very high temperatures so I can use a much more diffuse spot instead of focussing to a tiny point. High density polyethylene from milk bottles melts at only about 180°C. Here is one of the videos that inspired me:
http://www.youtube.com/watch?v=W_XUJwINdLw
and this young kid:
http://www.youtube.com/watch?v=rpXq6mnbCus
I'm considering forking out the money for an infrared non-contact temperature gauge (about $60), but I think I might need to find a way to accurately work out the temperature at the plastic instead of at the light spot.
https://www.jaycar.com.au/economy-non-contact-thermometer/p/QM7215
The milk bottles used as a temperature store in the little house don't need to be strong. They will just sit close to each other, but not touching, to let the air move all around them. They'll sit on grids of either welded steel reinforcing mesh (like that used in concrete foundations), or, if I can work out a way to make it, a polyethylene grid. This way they don't need to take any weight and don't need structural strength. They'll be there only to hold the water which will have great thermal inertia.
Flaps at the bottom and top of the heat stores will be opened to the room and/or the outside depending on the temperatures. The flaps will be controlled by my computer. It's tedious to do that by hand and I can make mistakes. At the moment my place gets heated and cooled by opening and closing my door during the day and night depending on temperatures. The thermal inertia of this place is pretty good (it's on a concrete slab) and it stays at about 23°C most of the time through heatwaves and cold snaps. I don't use a heater or cooler.
no subject
Date: 2017-12-10 02:03 pm (UTC)We're pretty light on for food waste. For me it's stuff like the scraps from onions, mostly.
My partner is a bit paleo and the like, but for all of that, we're never actually filled the composter to bursting.
I would like chickens, but Julie won't allow it. Being far out in the country we have rodents anyway.
But free EGGS!
The milk bottles used as a temperature store in the little house don't need to be strong.
no subject
Date: 2017-12-10 11:08 pm (UTC)