You are not logged in.

#1 2016-07-19 19:16:32

matmutant
Member
Registered: 2016-07-19
Posts: 39
Website

New to Bunsenlabs, new to cron, --help

Hello to everyone, first time here (and new to Bunsenlabs, coming from Mint [Cinnamon and Xfce editions])

I've just upgraded my netbook with an old SSD I had lying around (Intel 330, 60GB about 5TB of data already written on it) i couldn't stand the coffee machine sound of my HDD (WD Blue, 500GB)+ I switched from Mint 17.3 Xfce to Bunsenlabs (both to get a smaller / and smaller RAM footprint)

TL;DR: I'd need help performing TRIM via a cron job

I am not new to linux (but new to cron), but I'm far more used to Android than linux debugging; consider me as standard end-user today.

I don't mind killing the SSD with some swapping, but why not trying not to kill it too soon...

So I've read quite a lot about SSD and Linux these last few days and two choices are in there: discard flag in fstab or trim triggered by either cron job or rc.local

  • rc.local choice isn't a good one as it slows down the boot quite a lot on my baby.

  • discard flag isn't recommended (or at least some say so)

Looks like only cron job is left?

I read about cron, but how many cron services exists? like 6?

  • I found crontab and such in /etc, it does have some lines already,

  • systemctl says cron.service is active and running

  • but neither me or root has any cron jobs running?

  • putting script in /etc/cron.hourly doesn't seem to do anything


Existing /etc/crontab content:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

For now i run the trim job manually with the following:

date >> /home/matmutant/trim-output && sudo fstrim -v / >> /home/matmutant/trim-output


I'm pretty sure I've missed something while trying to learn, so if anyone could light my lantern with his Bunsen burner that would be great!

Thank you,
m@

Offline

#2 2016-07-19 19:34:02

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: New to Bunsenlabs, new to cron, --help

matmutant wrote:

TL;DR: I'd need help performing TRIM via a cron job

Why not use a systemd timer instead?

I use these unit files:

# /usr/lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/sbin/fstrim -a
# /usr/lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target

These are from my Arch system and are supplied with the fstrim package; to use them in BunsenLabs, place the fstrim.service and fstrim.timer unit files in /etc/systemd/system/ and use:

sudo systemctl enable fstrim.timer

I don't use cron, sorry :8

https://wiki.debian.org/CronAnacronAtBatchSchedulers

Offline

#3 2016-07-19 20:10:53

matmutant
Member
Registered: 2016-07-19
Posts: 39
Website

Re: New to Bunsenlabs, new to cron, --help

Head_on_a_Stick wrote:
matmutant wrote:

TL;DR: I'd need help performing TRIM via a cron job

Why not use a systemd timer instead?

hmmm because I didn't know about this option xD
If it's easier than cron I may try -tomorrow, it's never a good idea to test things tired-

Thank you for the answer by the way! I'll sure look into it

Offline

#4 2016-07-19 20:47:42

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: New to Bunsenlabs, new to cron, --help

I dont think cron is that difficult, but it pulls from various files. Some user configurable, some not, and some files that can be edited manually but shouldn't be. But ultimately I believe there is only one cron daemon running.

But yea the systemd unit idea may be more streamlined.  Plus the unit files are very modular and can be added and removed as you see fit.
jJust make sure you remember they're there and you keep track of which ones are your own service units so you can save them in case your system ever gets borked.

Last edited by Horizon_Brave (2016-07-19 20:50:18)


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#5 2016-07-20 17:35:53

matmutant
Member
Registered: 2016-07-19
Posts: 39
Website

Re: New to Bunsenlabs, new to cron, --help

Thank you both smile
I tried systemd timer ... successfully (and without loosing much hair xD)
i'm using the following:

# /etc/systemd/fstrim.service

[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/home/matmutant/scripts/trim3.sh
# /etc/systemd/fstrim.timer

[Unit]
Description=Discard unused blocks at boot
Documentation=man:fstrim

[Timer]
#OnCalendar=daily
OnBootSec=1min
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target
#!/bin/sh
#/home/matmutant/scripts/trim3.sh
OutputFile="/home/matmutant/trim-output"
Touch="/bin/touch"
Date="/bin/date"
Fstrim="/sbin/fstrim"
if [ ! -w "$OutputFile" ]; then
	#if file doesn't exist it is created
	$Touch "$OutputFile"
fi
#appends date to file and then performs trim to / dir
$Date >> "$OutputFile" && $Fstrim -v / >> "$OutputFile"

exit 0

Looks like it works quite nicely smile
I might use the same way to automate this too:

syndaemon -i 1 -t -d

Last edited by matmutant (2016-07-20 17:36:33)

Offline

#6 2016-07-20 21:15:45

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: New to Bunsenlabs, new to cron, --help

Fantastic work, I may have to "steal" your script big_smile

matmutant wrote:

I might use the same way to automate this too:

syndaemon -i 1 -t -d

It's probably best to add that line to ~/.config/openbox/autostart as it is a graphical program and it can be tricky to make custom unit files start under the X server.

Offline

#7 2016-07-20 22:11:05

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,143
Website

Re: New to Bunsenlabs, new to cron, --help

^ https://forums.bunsenlabs.org/viewtopic … 957#p32957

The current state of our development in that regard (we're probably adding syndaemon to disable the touchpad while typing, and disable the CapsLK key, as shown in that post). Note that this includes adjustments made for pulseaudio/volumeicon, posted here...

https://forums.bunsenlabs.org/viewtopic.php?id=2266


I don't care what you do at home. Would you care to explain?

Offline

#8 2016-07-21 15:07:30

matmutant
Member
Registered: 2016-07-19
Posts: 39
Website

Re: New to Bunsenlabs, new to cron, --help

hhh wrote:

^ https://forums.bunsenlabs.org/viewtopic … 957#p32957

The current state of our development in that regard (we're probably adding syndaemon to disable the touchpad while typing, and disable the CapsLK key, as shown in that post). Note that this includes adjustments made for pulseaudio/volumeicon, posted here...

https://forums.bunsenlabs.org/viewtopic.php?id=2266

Thanks, I've just added the syndaemon line to mine.
why disabling CapsLK though?

Head_on_a_Stick wrote:

Fantastic work, I may have to "steal" your script big_smile

cool
That's what it is meant to smile,
I tried not to hardcode paths of files and binaries so it could be used by anyone smile

It's also on my gihub [it is mostly for future me, after i'll have my install broke and restarting from scratch]

Offline

#9 2016-07-21 15:34:12

matmutant
Member
Registered: 2016-07-19
Posts: 39
Website

Re: New to Bunsenlabs, new to cron, --help

Next step:
trying to figure how to set up correctly thermal-conf.xml (from Thermald) my little netbook burns in the inside xD (70~80°C while typing this post, fan barely spinning)

Offline

#10 2016-07-21 20:16:33

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,143
Website

Re: New to Bunsenlabs, new to cron, --help

matmutant wrote:

why disabling CapsLK though?

Some of us look at the keys when we type, it stinks to look back up and half a paragraph IS CAPS LOCKED BECAUSE YOU TOUCHED THE KEY BY ACCIDENT>

Feel free to remove that line or comment it out. We're trying to add options in to show users they're available. It's easier to disable something you can see or use than to add something you don't know exists.


I don't care what you do at home. Would you care to explain?

Offline

#11 2016-07-21 21:08:14

matmutant
Member
Registered: 2016-07-19
Posts: 39
Website

Re: New to Bunsenlabs, new to cron, --help

hhh wrote:
matmutant wrote:

why disabling CapsLK though?

Some of us look at the keys when we type, it stinks to look back up and half a paragraph IS CAPS LOCKED BECAUSE YOU TOUCHED THE KEY BY ACCIDENT>

Feel free to remove that line or comment it out. We're trying to add options in to show users they're available. It's easier to disable something you can see or use than to add something you don't know exists.

ha right, didn't think of that, it also happens to me from time to time on kb I'm not used to -but it annoys me far far less than the touchpad ghost touch-  8o

Are there any cheat sheets that sum up "all" the BL specificities?
I fell in love with BL and openbox, so much I tried to turn off my Mint/Cinnamon PC with a right click roll

-gonna open a new thread later for the thermald related issue-

Offline

#12 2016-07-21 22:35:12

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,143
Website

Re: New to Bunsenlabs, new to cron, --help

matmutant wrote:

Are there any cheat sheets that sum up "all" the BL specificities?
I fell in love with BL and openbox, so much I tried to turn off my Mint/Cinnamon PC with a right click roll

This forum is very incomplete, it's a work in progress but us devs are busy working on deuterium (the next BL ISO) ATM. It needs some attention, so please add to it if you can...
https://forums.bunsenlabs.org/viewforum.php?id=21

I'm sure I had Mate set up with a right-click menu, but I'll have to get back to you on that!

-gonna open a new thread later for the thermald related issue-

Yes, please. Thanks, we're trying to give each issue it's own thread to making searching easier. Use a clear Subject Title too, that helps a lot!


I don't care what you do at home. Would you care to explain?

Offline

Board footer

Powered by FluxBB