Page 1 of 1

How to set a cron job?

Posted: Tue 13 Nov 2007, 23:15
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?

Posted: Wed 14 Nov 2007, 00:22
by trapster
Here might help

Posted: Wed 14 Nov 2007, 04:53
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

Posted: Wed 14 Nov 2007, 07:49
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

Posted: Wed 14 Nov 2007, 23:53
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.

Posted: Thu 15 Nov 2007, 03:46
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.

Posted: Thu 15 Nov 2007, 07:55
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

Posted: Thu 21 Jan 2010, 05:02
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...

cron variables

Posted: Sat 20 Feb 2010, 09:30
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

Posted: Mon 28 Jun 2010, 19:30
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

cron half working for me using frugal install Puppy 5.2.8

Posted: Sun 03 Nov 2013, 22:06
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?

Posted: Mon 04 Nov 2013, 23:04
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.

__________________________________________

Posted: Tue 05 Nov 2013, 04:37
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...