learning cron command

Help with D-Star related issues
Post Reply
KK6MYS
Posts: 10
Joined: Mon Feb 25, 2019 5:57 pm

learning cron command

Post by KK6MYS » Sun Apr 07, 2019 11:48 pm

I want to connect to xrf002a at 7pm on Thursday. If I paste the below command in to the expert->System Cron will it work?

Code: Select all

* 19 * * 4 sudo pistar-link xrf002_a

update 20190409
Solved

I used the below website to generate the time and dates.
https://crontab-generator.org/


Thanks for all help I was able to do it with the following.

It does not work when I do it using the expert> crontab in the pi-star interface. I had to SSH in to do it.

Code: Select all

ssh [email protected](ip address of pi-star)
type in password for your pi-star

make pi-star read write

Code: Select all

rpi-rw
Edit the crontab in nano text editor

Code: Select all

sudo crontab -e
here is what I pasted in at the bottom

Code: Select all

# the Young Persons' Net (XRF757A every Sunday at 15:59 PLT with a duration of 40 minutes then return back to ref001c                            
59 15 * * 0 /usr/local/sbin/pistar-link xrf757_a && sleep 2400 && /usr/local/sbin/pistar-link ref001_c
press control+x
press Y
press return

make pi-star read only

Code: Select all

rpi-ro
reboot

Code: Select all

sudo reboot
Last edited by KK6MYS on Tue Apr 09, 2019 4:32 pm, edited 4 times in total.

User avatar
W1KMC
Posts: 89
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: learning cron command

Post by W1KMC » Mon Apr 08, 2019 12:44 pm

I haven't heard of using cron in this way , but yours (if it did work for this) would connect every minute from 7 to 8 pm as your syntax is malformed.

0 19 * * 4 pi-star "sudo pistar-link xrf002a" > /dev/null 2>&1

and this assumes MY syntax is correct as I am not sure about the quotes for the command. (I am looking at a cron from another box I have and it shows full path, but maybe the command will work, maybe it won't)

in yours the 1st * would have executed every minute -- you only wanted top of the hour, use a zero
your hour and day and month and day of week were correct
you forgot the username, sometimes this is OK, but with pistar, I think you need it. Also you could try using root, but the way pistar works, it may not work as expected (and if you do, drop sudo and find the path to the pistar-link "script" and use it, but as for the "argument, I don't know if quoted are needed still.

A modified croin would be

0 19 * * 4 pi-star '/path/to/pistar-link xrf002a' > /dev/null 2>&1

Good Luck
I am no developer, guru, expert, nor do I claim to be or want to be. All advice I give is purely from experience and my efforts to help others.

W1KMC - Kevin M Carman
Bangor, ME
Jumbospot on a Pi0W
DMR 3123142 & 3123143
HHUS Trunk Ext 4329

KK6MYS
Posts: 10
Joined: Mon Feb 25, 2019 5:57 pm

Re: learning cron command

Post by KK6MYS » Mon Apr 08, 2019 1:58 pm

you are correct it does not work as intended. There must be a way to get it to work.

User avatar
w7efs
Posts: 244
Joined: Sun Apr 22, 2018 4:26 pm

Re: learning cron command

Post by w7efs » Mon Apr 08, 2019 3:04 pm

KK6MYS wrote:
Sun Apr 07, 2019 11:48 pm
I want to connect to xrf002a at 7pm on Thursday. If I paste the below command in to the expert->System Cron will ir work?

* 19 * * 4 sudo pistar-link xrf002_a
You need to pay careful attention to the column headings in the crontab file. Sunday is day 0 or 7 of the week, and your syntax will fail because a cron shell doesn't include /usr/local/sbin in the $PATH. For practice, set a cron job sometime in the next hour: "echo $PATH > /tmp/cron_path" and examine the file after it's written, comparing it with the value from your regular bash command line.

We link to XRF757A every Sunday at 15:59 PLT with a duration of 40 minutes for the Young Persons' Digital Voice Net, in hope of hearing the next generation of operators as they get a taste for radio via 3rd-party traffic. In root's crontab file we have:

Code: Select all

# m h   dom     mon     dow     command                                                                 
# the Young Persons' Net ...                                                                            
59 15 * * 0 /usr/local/sbin/pistar-link xrf757_a && sleep 2400 && /usr/local/sbin/pistar-link ref001_c
"man 5 crontab" is a very useful tool for understanding the details of the crontab file.
Last edited by w7efs on Mon Apr 08, 2019 5:25 pm, edited 3 times in total.

User avatar
KE0FHS
Posts: 846
Joined: Wed Apr 11, 2018 8:40 pm
Location: Colorado, USA
Contact:

Re: learning cron command

Post by KE0FHS » Mon Apr 08, 2019 4:06 pm

w7efs wrote:
Mon Apr 08, 2019 3:04 pm
... the Young Persons' Digital Voice Net, in hope of hearing the next generation of operators as they get a taste for radio via 3rd-party traffic.
That's so great!
73, Toshen, KE0FHS
Playing with Pi-Star (unofficial notes about setting up and using Pi-Star):
https://amateurradionotes.com/pi-star.htm

User avatar
w7efs
Posts: 244
Joined: Sun Apr 22, 2018 4:26 pm

Re: learning cron command

Post by w7efs » Mon Apr 08, 2019 5:12 pm

The NCO (net control operator) Danielle KE8JNU was Amateur Extra at age 9. With more experience at age 10, she's now training some other children to occasionally take over as NCO.

User avatar
KE0FHS
Posts: 846
Joined: Wed Apr 11, 2018 8:40 pm
Location: Colorado, USA
Contact:

Re: learning cron command

Post by KE0FHS » Mon Apr 08, 2019 8:38 pm

w7efs wrote:
Mon Apr 08, 2019 5:12 pm
The NCO (net control operator) Danielle KE8JNU was Amateur Extra at age 9. With more experience at age 10, she's now training some other children to occasionally take over as NCO.
Bravo!
73, Toshen, KE0FHS
Playing with Pi-Star (unofficial notes about setting up and using Pi-Star):
https://amateurradionotes.com/pi-star.htm

User avatar
W1KMC
Posts: 89
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: learning cron command

Post by W1KMC » Tue Apr 09, 2019 12:56 pm

Thanks w7efs, you taught me something.

As I posted, I didn't think my modification would work either (wasn't sure about the quotes or having a space for arguments. Yours also strings 3 commands together with the && .

See even I can be taught a new thing.

One night I think I caught the Young people's net on the DMR side of things. I don't have DStar where I live and to get a radio to do DStar on just a hotspot for me just isn't practical.

Thanks again.
I am no developer, guru, expert, nor do I claim to be or want to be. All advice I give is purely from experience and my efforts to help others.

W1KMC - Kevin M Carman
Bangor, ME
Jumbospot on a Pi0W
DMR 3123142 & 3123143
HHUS Trunk Ext 4329

Post Reply