How to set a cron job?

Booting, installing, newbie
Post Reply
Message
Author
StevenR
Posts: 2
Joined: Tue 13 Nov 2007, 21:26

How to set a cron job?

#1 Post by StevenR »

I have my scripts ready. They're in /usr/local/bin. They're executable. I've tested them.

But I can't seem to get the cron job to work.

Since Puppy has no vi, crontab -e doesn't work.

I'm trying to use Gcrontab, but I'm not sure how it works.

This page is no help: http://www.arquired.es/users/aldelgado/proy/gcrontab/

And I have yet to find any explanation of how to make the cron jobs work.

Does anybody have a tutorial or any kind of documentation for Gcrontab?

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#2 Post by trapster »

Here might help
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#3 Post by HairyWill »

zigberts Pschedule seems a lot more intuitive than gcrontab. Here is the thread where you can get it:
http://www.murga-linux.com/puppy/viewtopic.php?t=22166
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

User avatar
paulh177
Posts: 975
Joined: Tue 22 Aug 2006, 20:41

#4 Post by paulh177 »

As a thread of mine got namechecked, I'll summarise what I did:
  • Make sure your system timezone, date and time is set correctly
    Make sure cron is starting -- put

    Code: Select all

    /usr/sbin/crond -L /tmp/cronjobs.log
    in your rc.local. You can use whatever logfile name and location you like of course, but just having one could help track down problems.
    Reboot and check with ps that cron is running.
    Use Gcrontab or pschedule (both are OK even if needing a little work yet) to set up a test schedule - or if like me you're a sick man, use e3vi to create one from scratch.
    I set up a little scriptfile to echo a few characters to a file.
    Set the schedule to say 15 mins in the future, and reboot again.
    Watch for the output of your test, and watch the output of your logfile (I used tail -f /tmp/cronjobs.log)
Various threads on various boards seemed to indicate that stray characters in the /var/spool/cron/crontabs/root file could cause cron to fail, and although I edited the file produced by pschedule and Gcrontab, and cron started to work, I am not convinced that that was the problem with my setup -- I think it was coincidental.
But it's worth a try if yours doesn't work.

The time/date/timezone thing is really important, because otherwise cron might be working but isn't on the same clock as you (!).

As an example, I had the wrong time/TZ set on a gentoo system; I was building it using cron to schedule an emerge; cron triggered a massive download when I wasn't expecting it and I ended using a great lump of my broadband account's download limit in one hit ...

Getting something like this to work when you're struggling means taking a stepwise approach, changing only one thing at a time, and testing after each change. I say that because I'm crap at doing just that and go in scattergun too often, but it's rarely an effective approach, and if it does fix something, I'm never sure what fixed it.

Hope this is of help

Paul

StevenR
Posts: 2
Joined: Tue 13 Nov 2007, 21:26

#5 Post by StevenR »

That worked. That line to get crond running was the "missing piece."

Thanks!

I still think Gcrontab is barbaric. I'm a little hazy on what you do to make your crontab active. In Gcrontab, I open my crontab file (I saved it as /etc/crontab, although I'm not sure that's mandatory) and "set current file."

I'd love to be able to edit it with Geany, e3 or whatever and let that be that, but I think that I need Gcrontab to make it active.

I did have to create the file in Geany because I needed the first part to be */5 (to run the job every five minutes) and I couldn't get Gcrontab to do that. But then I had to open the crontab file in Gcrontab and "set" it ...

At any rate, it's working, and I thank you all.

User avatar
alienjeff
Posts: 2265
Joined: Sat 08 Jul 2006, 20:19
Location: Winsted, CT - USA

#6 Post by alienjeff »

Remember that crontab and crond are symlinks to BusyBox, so these apps are probaby going to be different than those of core apps in standard distros - just in case that's from where you're drawing experience.
[size=84][i]hangout:[/i] ##b0rked on irc.freenode.net
[i]diversion:[/i] [url]http://alienjeff.net[/url] - visit The Fringe
[i]quote:[/i] "The foundation of authority is based upon the consent of the people." - Thomas Hooker[/size]

User avatar
paulh177
Posts: 975
Joined: Tue 22 Aug 2006, 20:41

#7 Post by paulh177 »

StevenR wrote:I'm a little hazy on what you do to make your crontab active ... I think that I need Gcrontab to make it active.
Bearing in mind alienjeff's apposite comment, my understanding of cron is that, so long as it is running, the only other thing it needs is the presence of the user file in the correct place. i.e. cron runs as a daemon and its job is to check for the existence of the file, and if it exists read it and if there is a job to be executed in the minute of checking, execute it.

Gcrontab is only a way of maintaining /var/spool/cron/crontabs/root (or whatever user) so far as I can see, althought "barbaric" is a little strong!

I have little experience of cron except getting it running on puppy so if I'm wrong in any matters of fact I hope someone will correct me.

paul

Wavy
Posts: 1
Joined: Thu 21 Jan 2010, 04:56

#8 Post by Wavy »

/usr/sbin/crond -L /tmp/cronjobs.log
Thanks, cron is now running smoothly! I ran this through the command line and everything came to life. Even though the thread is over two years old, the advice is still good. I just started playing with Puppy 4.3.1 and can finally sit back and watch some PHP scripts run automatically. Now to add the command to the startup script...

MeKino
Posts: 8
Joined: Sat 13 Feb 2010, 07:11

cron variables

#9 Post by MeKino »

Hi,

I am trying to set up a cron job where the output is to a file and the filename is appended with the date & time.

I have been able to do this before using -%d-%m-%Y-%H:%M but this does not work in Puppy.

Does anybody have any ideas?

Thanks for your help.

Kino

User avatar
enhu
Posts: 302
Joined: Wed 27 May 2009, 02:13
Contact:

#10 Post by enhu »

anyone might just want to share a script which i can use in cron to work please:D

i'm trying to learn bash:D

Questor
Posts: 2
Joined: Sun 03 Nov 2013, 21:27

cron half working for me using frugal install Puppy 5.2.8

#11 Post by Questor »

I can execute my script in RoxTerm just fine. The script is
perl -T youtube_wget_video.pl http://www.youtube.com/watch?v=Fh4wKUnoKtw mp4

When I put this same script in Pschedule, it does not run.
My time and date and time zone is set correctly

I can run a basic hello world script OK using Pschedule.

Pschedule wont EXECUTE NOW my youtube script either.

sh-4.1# ps -ef | grep cron | grep -v grep gives me the following output.
root 6408 1 0 15:09 ? 00:00:00 /usr/sbin/crond -L /tmp/cronjobs.log

plus I know cron is running because it does a delayed "hello world" output to the screen.

I've put /usr/sbin/crond -L /tmp/cronjobs.log
in my rc.local.

but cronjobs.log always has a zero size. Nothing gets logged to it.

I've opened /var/spool/cron/crontabs/root and looked for extra char's. I found none.

I would like to eventually be able to use Pschedule or cron to download youtube videos from midnight to 6a and do hard disk backups during these hours too.

Any thoughts as to what I may be doing wrong?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#12 Post by don570 »

You should post in the pschedule thread and Zigbert might answer.

I'm not an expert but other Puppy users seem to use
the wget command to download???

_____________________________

Zigbert has written a script called pclock

One of the features is to execute a command after a certain number of
minutes over and over. (It's not explained very well by Zigbert
so few people know of the feature)

You should try it as well.

__________________________________________

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#13 Post by RetroTechGuy »

don570 wrote:You should post in the pschedule thread and Zigbert might answer.

I'm not an expert but other Puppy users seem to use
the wget command to download???
For vids, I use the Firefox plugin "Video Downloadhelper"

https://addons.mozilla.org/en-US/firefo ... src=search

Click on the down-arrow icon that appears next to the rotating "atom". Select format/size and save it somewhere.

Of course, that doesn't give you a way to chron job it to run in the middle of the night...
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

Post Reply