View topic - Cron - Crontab

Page 1 of 2

Cron - Crontab

PostPosted: Tue Oct 04, 2005 3:37 pm
by elmasciruja
Hi, i`m not really good with my english and i don`t know much in Qnx.
I have to run an application every hour.
I read that cron and crontab do that.
But the problem is that i try to configure it bau it really don`t work.
Please if someone write the steps to do that.

Thanks a lot.

Martin (From Argentina)

RE: Cron - Crontab

PostPosted: Tue Oct 04, 2005 5:09 pm
by noc
This page should get you started.

Post back the actually steps/errors if you still have problems.

PostPosted: Wed Oct 05, 2005 1:20 pm
by elmasciruja
Y start the cron like this

Cron -L -V
and in /usr/spool/cron.1/crontab/root

Y edited this

0 * * * * (sh -c path of the program) > /dev/con1

Mi question is:+
Is there any chance that the program executes every 15 minutes¿?

PostPosted: Wed Oct 05, 2005 2:24 pm
by SmeeAgain
from the docs:
Display the current time on the system console every 20 minutes:

1,21,41 * * * * (echo -n " "; date; echo) > /dev/con1

So for you it's just something like:
0,15,30,45 * * * * do_something

RTFM

PostPosted: Wed Oct 05, 2005 2:35 pm
by elmasciruja
Hi, i change te values fron 0,15,30,45 but still it doing every hour.
Is there any chance to stop the cron and start again ?

PostPosted: Thu Oct 06, 2005 12:05 am
by noc
Depending on how you modified the "crontab" file, you may need to restart "cron".

PostPosted: Thu Oct 06, 2005 2:43 pm
by elmasciruja
Two queestiosn:
1) How can i restart cron
2)Every time i reboot the machine i have to start Cron -L -v again.
Is there any chance that cron start automatically when i rebbot the machine???

Sorry again for my english

PostPosted: Thu Oct 06, 2005 4:38 pm
by noc
I guess you made a typo of "Cron -L -v"? It should be a lower case C like "cron".

To restart, you first kill it and then start it again:
slay cron
cron -L -v &

To make it auto start, you need to add it into /etc/config/sysinit.1 (assuming you are on node 1).

Please post the output from the following commands:

id
echo $NODE
ls -l /usr/spool/cron.1/crontab/
(you mentioned /usr/spool/cron.1/crontab/root in your above post, but I guess you must have made a typo).
ls -l /usr/spool/cron.1/crontabs/

PostPosted: Thu Oct 06, 2005 5:58 pm
by elmasciruja
Hi, the outputs of the commands are:

id:
uid=0 (root) gid=0 (root)

echo $NODE
1

ls -l /usr/spool/cron.1/crontabs/
Total 17

dr-xr-xr-x 2 root root 4096 oct 04 16:06.
dr-xr-xr-x 3 root root 4096 oct 04 10:29..
-rw-rw-rw-1 root root 66 oct 06 9:27 root

What can i do to put in sysinit.1 ?

Thanks a lot

PostPosted: Thu Oct 06, 2005 8:12 pm
by WhiteRabbits
you can put the line
cron -L -v &
into your sysinit.1 file.

for editing sysinit.1 :
type :
vi /etc/config/sysinit.1 with (ENTER)
or type :
vedit /etc/config/sysinit.1 with (ENTER)

for detailed information about vi visit :
http://www.qnx.com/developers/docs/qnx_ ... /v/vi.html

do not use a DOS or WINDOWS based texteditor to create or modify QNX related files.

good luck !
HELGE

PostPosted: Thu Oct 06, 2005 8:30 pm
by elmasciruja
What is the difference between "cron -L -c &" and "cron -L -c"

Thanks a lot for all of the responses.

Martin (Argentina)

PostPosted: Fri Oct 16, 2009 1:54 pm
by Pogoda
Good evening! Please help. I'm trying to start some executable file in cron, and it isn't start. And example with "echo..." not enough. :( I write in my crontab:
45 16 16 10 0-6 /tmp/myprog
What mean start exutable file by adress /tmp/.. at this time. What's wrong here? It needs to write PATH in environment variables?
Or I must write something like this? :
45 16 16 10 0-6 /tmp/myprog>/dev/con1

Thank you!

p.s. Sorry of my english.

PostPosted: Fri Oct 16, 2009 7:47 pm
by juanplacco
1) is cron running? :D

2) What does your program actually do?

3) Try somthing like

* * * * * echo "Hi!" > /tmp/hi.txt

in crontab

4) Edit crontab entries with crontab -e.

5) Then check these entries with crontab -l

6) Check /tmp/hi.txt after a minute

7) Does it work?

PostPosted: Sat Oct 17, 2009 6:19 am
by Pogoda
1) Yes, run it with command cron &
2)Program - executable file which move files from qnx fiel system to ntfs (smb mounted). At first I can't move it cause attributes don't write, and I replace moving to 2 actions: copy and removing files from initial directory. It works perfect when I start it manually from shell.
3)I made this example from one qnx book : * * * * * echo "Hi!">/dev/con1 and it write word "Hi" in shell in con1.
4) Editing crontab with vi? I can't understand how works with it. What command I must write to change editor to vedit?
5)I can see it. Is it terrible what I edit crontab withh key F4 in "Midnight Commander"?
6) I write answer in 3)
7)Yes it works, but how start my executable fiel?
I must logging it work like: /tmp/myprog > /tmp/hi.txt ?

PostPosted: Sat Oct 17, 2009 10:08 pm
by juanplacco
You can export EDITOR environment variable to use your preferred editor.

So, I still don't gen your point. You have to keep in mind than cron does not inherit the environment variables. So if your program runs normally from the console but not when cron spawned it, you should check which environment variables your program need to run.