LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


View Poll Results: How long would it take you to create a correct cron job for any given frequency without referencing
I could do it immediately for any frequency I'm given. 1 3.45%
I would need to sit and think for a minute or so. 8 27.59%
I could work my way through it in 15 minutes or less. 1 3.45%
*maybe* I could manage one on my own if it's a simple and common one 2 6.90%
I couldn't do it from memory. I would need to reference examples/documentation. 15 51.72%
What is a cron job? 2 6.90%
Voters: 29. You may not vote on this poll

Reply
  Search this Thread
Old 04-12-2017, 06:26 PM   #1
Cultist
Member
 
Registered: Feb 2010
Location: Georgia
Distribution: Slackware64 14.2
Posts: 779

Rep: Reputation: 107Reputation: 107
How good are you at creating new cron jobs from memory?


Just a question I was curious about.

My full question:
Without referencing documentation or example crons of any kind, how easily could you create a new job for any given frequency?
 
Old 04-12-2017, 07:59 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Phooey on cron! I hope that I never have to touch a crontab again!

In my humble, "it's systemd to the rescue" here. I have vastly more options available to me when I use its timer facility.
 
Old 04-13-2017, 08:04 AM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,367

Rep: Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748
In my humble, I think it is raining when a dog pees on my leg.

OT - My crontabs contain contain commented lines, easily adjusted to serve my purposes.
 
Old 04-13-2017, 08:36 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
I pick what is CRon job, even though I know what it is. but I've never not once used it per se' . I have however created a script that I want ran once a week then just moved it into "cron.weekly" chmod +x scriptName -- done.

Last edited by BW-userx; 04-13-2017 at 08:38 AM.
 
Old 04-13-2017, 09:09 AM   #5
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
I just keep this at the top of my crontab file so I don't have to worry about remembering..

Code:
# minute (0-59) hour (0-23) day (1-31) month (1-12) day of week (0-6)
 
1 members found this post helpful.
Old 04-13-2017, 09:49 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
What "memory"?

I think I have CRS
 
Old 04-13-2017, 09:55 AM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
It's second nature.

I do have a commented out block at the top of all of my crontabs just in case I space out though:
Code:
#
# Cron's default PATH:
#    /usr/bin:/bin
#
#   *  *  *  *  *  command to be executed
#   -  -  -  -  -
#   |  |  |  |  |
#   |  |  |  |  +----- day of week (0 - 6) (Sunday=0)
#   |  |  |  +------- month (1 - 12)
#   |  |  +--------- day of month (1 - 31)
#   |  +----------- hour (0 - 23)
#   +------------- min (0 - 59)
 
Old 04-13-2017, 11:52 AM   #8
petelq
Member
 
Registered: Aug 2008
Location: Yorkshire
Distribution: openSUSE(Leap and Tumbleweed) and a (not so) regularly changing third and fourth
Posts: 627

Rep: Reputation: Disabled
Quote:
Originally Posted by orbea View Post
I just keep this at the top of my crontab file so I don't have to worry about remembering..

Code:
# minute (0-59) hour (0-23) day (1-31) month (1-12) day of week (0-6)
I like that. Thanks. (I used to look it up every time!)
 
Old 04-13-2017, 02:56 PM   #9
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
man systemd? TL;dr -> Show me how to get sysd to do this

semiOnTopic, I've seen enuf threads about "my cronjob doesn't work", because of like path needed, quoting/gobbledygook needed cuz it's in crontab, etc., to scare me into "believing" cron might likely NOT work (for me)! LQsearch: Threads Titled cron* finds 1000!

Which leads me to be terrified of the "impossible" sysdMonster (ooops, lets NOT debate/discuss/mention sysd ... How did it get in this thread in the first place... Don't answer that: it will spoil my web search ending )

Edit: answer: OmyGosh, it's too late: it's already happened! The web is infested with such info, e.g. https://blog.higgsboson.tk/2013/06/0...n-replacement/ RIP cron; a new world order awaits my conquest!

p.s. Could you freely explain extra cost for CRS ram?
And I've decided to wait until sysd can properly read my mind, no matter how muddled it is.

Last edited by !!!; 04-13-2017 at 03:58 PM.
 
Old 04-13-2017, 04:34 PM   #10
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by !!! View Post
semiOnTopic, I've seen enuf threads about "my cronjob doesn't work", because of like path needed, quoting/gobbledygook needed cuz it's in crontab, etc., to scare me into "believing" cron might likely NOT work (for me)! LQsearch: Threads Titled cron* finds 1000!
99.999% of crontab problems are from people who don't realize cron doesn't parse the system-wide or per-user shell setup scripts (.bashrc or similar) before executing, and therefore doesn't share all of the environment variables they're used to working with (most notably PATH). They also don't bother to redirect the output of their command to a log file, and then have no way of knowing what's wrong when it doesn't execute.

Two steps will eliminate basically all cron problems:
1) Run "export PATH=/usr/bin:/bin" before running the cron command interactively on your shell to see if it complains about any missing programs.
2) Add " >> $HOME/logfile 2>&1" to the end of your cron command when first adding it. If things aren't working right check ~/logfile to see what the output is, otherwise you can change the redirect to /dev/null to throw it away.
 
2 members found this post helpful.
Old 04-14-2017, 02:00 PM   #11
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Thanks #10: I'm "cured" (of my "fear")! The very next post about cron that I ran into, was a path issue, and escaping the % in date (where cron takes % as a newline: WoW!). Now I believe "that's all there is to it"! Cool!
 
Old 04-17-2017, 09:32 PM   #12
wolsonjr
Member
 
Registered: Aug 2007
Location: IL/US
Distribution: Deb, Mint, Slack, LFS, Fedora, Ubuntu(LXDE)
Posts: 71

Rep: Reputation: 34
Love cron, my crontab is 80+ lines long, automation to the rescue. With lots of at for one-offs.
I also have a special pipe that runs in a dedicated term where my cronjobs output pertinent info for me.
 
Old 04-19-2017, 05:46 AM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,355

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Re post #7: actually that hdr is std on Centos 6 in /etc/crontab
 
Old 04-19-2017, 07:53 AM   #14
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by chrism01 View Post
Re post #7: actually that hdr is std on Centos 6 in /etc/crontab
I always wondered where I found it, that must be it!
 
Old 04-19-2017, 06:11 PM   #15
e_james
LQ Newbie
 
Registered: Feb 2006
Posts: 27

Rep: Reputation: 0
I use the "Scheduled Tasks" gui but it still needs a little bit of thought.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron job starts 6 hours late, rest of cron jobs work fine pieterhouwen Linux - Newbie 33 10-05-2015 12:38 PM
Where are cron jobs located when not under /var/spool/cron/root? NotionCommotion Linux - Newbie 6 09-07-2012 07:33 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
Creating Cron Jobs simba_cubs Linux - General 1 09-27-2006 05:42 PM
creating cron jobs jonfa Linux - General 5 05-26-2002 05:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration