Cron - Crontab

Hi, im not really good with my english and i dont 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)

This page should get you started.

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

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¿?

from the docs:

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

RTFM

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 ?

Depending on how you modified the “crontab” file, you may need to restart “cron”.

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

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/

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

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 :
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

What is the difference between “cron -L -c &” and “cron -L -c”

Thanks a lot for all of the responses.

Martin (Argentina)

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. :frowning: 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.

  1. is cron running? :smiley:

  2. What does your program actually do?

  3. Try somthing like

          • echo “Hi!” > /tmp/hi.txt

in crontab

  1. Edit crontab entries with crontab -e.

  2. Then check these entries with crontab -l

  3. Check /tmp/hi.txt after a minute

  4. Does it work?

  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.
  2. 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”?
  3. 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 ?

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.

Ok! Thanks! I’m understand! :smiley: Maybe my program runs with cron and system utility “sin” too. But I can’t see their work, cause I don’t write this:
“> /dev/con1” after command. I write simply:

          • sin
        • */tmp/myprog
          And maybe it runs, but don’t show.

Must write like this:

          • sin>/dev/con1
        • */tmp/myprog>/dev/con1

Is it right? Or how you advice me , to make log.

          • sin > /tmp/hi1.txt
        • */tmp/myprog > /tmp/hi2.txt
          p.s. I check environment variables and directory /bin/ to run system utilities is written.

So it works!