LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   What do slackers put in cron.* (https://www.linuxquestions.org/questions/slackware-14/what-do-slackers-put-in-cron-%2A-4175441563/)

g4ry 12-15-2012 10:14 AM

What do slackers put in cron.*
 
I've just started looking into using cron, which I'm fairly new to linux. I've written a script to sync my time daily but was wondering what others use cron for?

Thanks

malekmustaq 12-15-2012 10:50 AM

Quote:

Originally Posted by g4ry (Post 4849871)
I've just started looking into using cron, which I'm fairly new to linux. I've written a script to sync my time daily but was wondering what others use cron for?

Thanks

Usually for system maintenance tasks.

tronayne 12-15-2012 11:23 AM

... and see man crontab for how to write an entry.

Note, you use crontab -e to edit a crontab file.

Hope this helps some.

jmccue 12-15-2012 12:06 PM

What I have in my personal crontab:

1. remove vim/emacs backup files older than 30 days, once per day
2. get weather data from noaa for conky, twice per day
3. download any Slackware patches that exists twice a month

John

Habitual 12-15-2012 12:55 PM

Quote:

...what others use cron for?
Avoiding Repetitive Tasks.

onebuck 12-15-2012 03:46 PM

Member Response
 
Hi,

Or to run tasks on timely basis. :)

w1k0 12-15-2012 04:02 PM

I use cron to run every six minutes the script that among the other things downloads new mail using POP3, checks whether new patches for Slackware appeared, and stores the ChangeLog.txt file locally.

ttk 12-15-2012 07:55 PM

I chmod 000 /etc/cron.daily/slocate to cut down on my disks' wear-and-tear, and run an analogous command by hand perhaps three times per year.

Like you, I add rsetdate to /etc/cron.daily. On my personal server in the colo I also added a script that downloads the Slackware changelog and emails any new entries to myself and some friends:
http://ciar.org/ttk/public/slacklog.pl

frankbell 12-15-2012 09:25 PM

I run my podcatcher (I'm currently using podget) to pick my podcasts at 04:00 every morning.

kooru 12-16-2012 03:09 AM

Backup, update my custom motd, mail notification in case of alarm, and other things..

g4ry 12-16-2012 05:45 AM

Thanks for your replies. @w1k0, I like the idea of checking for patches and maybe mailing them to root. Other ideas I had was to periodically run programs like aide and rkhunter, or would that be better done from a live distro?

Another thing I was thinking about was retrieving gmail, does anyone do this?

interndan 12-16-2012 08:53 AM

I have a script in cron.daily to sync my system clock with a time server.

onebuck 12-16-2012 08:57 AM

Member Response
 
Hi,

'Time' is one that I do on a regular 'cron' task. Be sure to use a 'pool' so the load is handled properly.

GazL 12-16-2012 10:47 AM

I don't make much use of cron as I'm more of a ad-hoc kind of guy. Maybe if I left my system up 24x7 then I'd do things differently, but my box sleeps when I sleep.
:)


Quote:

Originally Posted by ttk (Post 4850133)
I chmod 000 /etc/cron.daily/slocate to cut down on my disks' wear-and-tear, and run an analogous command by hand perhaps three times per year.

I think you're proably right to disable it. slocate/updatedb may make sense on a server with millions of files, but for a modern desktop/workstation that has more than enough ram to keep inodes/dirents in vfs_cache I'm not convinced a database based solution like slocate makes any sense..

I have this in my .bashrc, which I use instead and will pretty much do the same job as an "slocate -i" does without the need to run updatedb.
Code:

function qlocate()
{
    find "$HOME" /local -xdev -readable -ipath "*${1}*" 2>/dev/null
}


qweasd 12-16-2012 01:08 PM

Quote:

Originally Posted by g4ry (Post 4849871)
I've written a script to sync my time daily but was wondering what others use cron for?

I mirror the host with rsync and sync the system time with sntp, both daily.

ttk 12-16-2012 04:32 PM

Quote:

Originally Posted by g4ry (Post 4850288)
Another thing I was thinking about was retrieving gmail, does anyone do this?

Yes! Your gmail is available via IMAP, and mbsync works quite nicely to retrieve it all.

This is my ~/.mbsyncrc, with some sekrit parts swapped out with "foo", "YOURGMAILPASSWORD", "YOURGMAILLOGIN", or "YOURNAME":

Code:

Expunge None
Create Both
MaildirStore local
Path /home/YOURNAME/Maildir/
Trash Trash

IMAPStore foo
Host imap.gmail.com
UseIMAPS yes
User YOURGMAILLOGIN
Pass YOURGMAILPASSWORD
CertificateFile /etc/pki/tls/certs/ca-bundle.crt
RequireSSL yes

Channel foo
Master :foo:
Slave  :local:
Sync PullNew

With this in place, the command "mbsync foo" pulls all of my gmail messages into ~/Maildir/

Come to think of it, putting this in /etc/cron.weekly seems like a pretty good idea. I will do that.

g4ry 12-17-2012 05:42 AM

@ttk thanks for your example config file, I added my info onto mine but when I run mbsync foo it complains about /etc/pki/tls/certs/ca-bundle.crt no such file or directory. Is there a package I'm missing, or is there something I need to do to create it?

Ok, sorted the cert issue out but I'm having trouble with Maildir

Reading configuration file /home/me/.mbsyncrc
Resolving imap.gmail.com... ok
Connecting to 173.194.66.108:993... ok
Connection is now encrypted
Logging in...
Channel foo
Selecting slave INBOX... Maildir error: '/home/me/Maildir/' is no valid mailbox

Thanks.

ttk 12-17-2012 09:40 AM

Quote:

Originally Posted by g4ry (Post 4850836)
@ttk thanks for your example config file, I added my info onto mine but when I run mbsync foo it complains about /etc/pki/tls/certs/ca-bundle.crt no such file or directory. Is there a package I'm missing, or is there something I need to do to create it?

Thanks.

I don't remember where I got mine, but looking at the comments in the file itself it appears to be derived from the mozilla sources:

Code:

## ca-bundle.crt -- Bundle of CA Root Certificates
##
## Converted at: Tue Sep 22 09:25:27 2009 UTC
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
## file (certdata.txt).  This file can be found in the mozilla source tree:
## '/mozilla/security/nss/lib/ckfw/builtins/certdata.txt'
##
## It contains the certificates in PEM format and therefore
## can be directly used with curl / libcurl / php_curl, or with
## an Apache+mod_ssl webserver for SSL client authentication.
## Just configure this file as the SSLCACertificateFile.
##

I see a mozilla-1.9.2/security/nss/lib/ckfw/builtins/certdata.txt in a firefox source tarball, but it's not obvious to me how to extract ca-bundle.crt from certdata.txt.

Aha -- here's a script which claims to do it all for you. I haven't tested it, but see if it works for you:
http://www.floodgap.com/software/tty...-ca-bundle.txt

Alternatively, if you're feeling trusting, you could just download the file I've been using here:
http://ciar.org/ttk/public/ca-bundle.crt.txt

ttk 12-17-2012 09:43 AM

Quote:

Originally Posted by g4ry (Post 4850836)
Selecting slave INBOX... Maildir error: '/home/me/Maildir/' is no valid mailbox
Thanks.

It's a bit picky about its Maildir format. This should work:
# mkdir -p /home/me/Maildir/cur /home/me/Maildir/new /home/me/Maildir/tmp
# chmod -R 700 /home/me/Maildir

g4ry 12-17-2012 09:57 AM

Thanks ttk, that worked :) ... I got my ca-certificates.crt in /etc/ssl/certs/ and it seems to work fine, whether that's the correct thing to do. I'll have a look at your links though. What do you use to read your mail from your inbox?

ttk 12-17-2012 10:20 AM

Quote:

Originally Posted by g4ry (Post 4850982)
Thanks ttk, that worked :) ... I got my ca-certificates.crt in /etc/ssl/certs/ and it seems to work fine, whether that's the correct thing to do. I'll have a look at your links though. What do you use to read your mail from your inbox?

"grep" and "less", mostly :-) I primarily use it for searching. But mutt reads from a Maildir quite nicely too.

You'll want to read this: http://www.elho.net/mutt/maildir/

g4ry 12-17-2012 10:53 AM

Thanks once again ttk, everything seems to be working fine and mutt works great after that link you posted.

Cheers :)

ttk 12-17-2012 12:06 PM

Yay! :-) I'm glad it works for you.

I just added this as /etc/cron.weekly/archive-gmail.sh:

Code:

#!/bin/sh
su -l -c '/usr/bin/mbsync foo' ttk

Triggering it manually (as root) appears to do the expected thing.

Beelzebud 12-17-2012 03:01 PM

I use a cronjob to update a bash script every 5 mins that will echo to /etc/issue, so that when I open a terminal I see correct and updated values for HDD space, uptime, etc.

Diantre 12-17-2012 03:50 PM

Among other things (backups, clean up tasks, etc.), I have a crontab entry to backup the crontab itself, just in case I screw it up, which has happened before.

Code:

5 17 * * sun crontab -l | gzip - > $HOME/Backup/crontab-$(date +%Y%m%d_%H%M%S).gz

Poprocks 12-18-2012 07:26 PM

Personally I don't know why anyone would use mbsync when Slackware comes with perfectly good copies of fetchmail and getmail, but I digress.

Personally I use cron to run getmail every minute for my user account. My root's crontab is mainly used to do my nightly backups using rsync. I use /etc/cron.daily for this. Since I don't really use my root's mailspool for anything but receiving system messages, I turn off root crontab's default configuration of directing all system output to /dev/null and make it only output STDOUT to /dev/null.

That way, if an error occurs with my backup, the root user will get an email notifying me of same.


All times are GMT -5. The time now is 10:48 AM.