learning cron command

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

learning cron command

Post by KK6MYS »

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 pi-star@(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: 133
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: learning cron command

Post by W1KMC »

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 »

you are correct it does not work as intended. There must be a way to get it to work.
User avatar
w7efs
Posts: 335
Joined: Sun Apr 22, 2018 4:26 pm

Re: learning cron command

Post by w7efs »

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: 1122
Joined: Wed Apr 11, 2018 8:40 pm
Location: Colorado, USA
Contact:

Re: learning cron command

Post by KE0FHS »

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: 335
Joined: Sun Apr 22, 2018 4:26 pm

Re: learning cron command

Post by w7efs »

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: 1122
Joined: Wed Apr 11, 2018 8:40 pm
Location: Colorado, USA
Contact:

Re: learning cron command

Post by KE0FHS »

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: 133
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: learning cron command

Post by W1KMC »

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
n2kto
Posts: 10
Joined: Sat Aug 17, 2019 12:01 pm

Re: learning cron command

Post by n2kto »

So I tried to follow what is required to create a cron script to my existing script in pi-star but after applying changes to the cron and then rebooting the PI it does not work. What am I missing. I went to Expert/System Cron and made some changes. This is what my PI's cron looks like now.

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""

# m h dom mon dow user command
*/5 * * * * root /usr/local/sbin/pistar-upnp.service start > /dev/null 2>&1 &
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 3 * * * root mount -o remount,rw / && cd / && run-parts --report /etc/cron.daily
47 3 * * 7 root mount -o remount,rw / && cd / && run-parts --report /etc/cron.weekly
52 3 1 * * root mount -o remount,rw / && cd / && run-parts --report /etc/cron.monthly
# all above is original scriping from the author
# [email protected] Dave Hubbell
# m h dom mon dow command
# Young Operators Digital Voice Net Control Danielle KE8JNU
59 20 * * 0 /usr/local/sbin/pistar-link xrf757_a && sleep 2400 && /usr/local/sbin/pistar-link ref069_c
# m h dom mon dow command
# K3PDR D-STAR NET JEFF
50 19 * * 1 /usr/local/sbin/pistar-link ref020_a && sleep 2700 && /usr/local/sbin/pistar-link ref069_c
# m h dom mon dow command
# The Multi Mode Digital Voice Net run by Jeff VE6DV
50 17 * * 6 /usr/local/sbin/pistar-link xrf757_a && sleep 3600 && /usr/local/sbin/pistar-link ref069_c
AF6VN
Posts: 821
Joined: Fri Jul 20, 2018 1:15 am

Re: learning cron command

Post by AF6VN »

The obvious factor...

The system-wide crontab file needs to specify the USER under which an operation is meant to run. As stated in the comments at the very top
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
Compare:
47 3 * * 7 root mount -o remount,rw / && cd / && run-parts --report /etc/cron.weekly
52 3 1 * * root mount -o remount,rw / && cd / && run-parts --report /etc/cron.monthly

59 20 * * 0 /usr/local/sbin/pistar-link xrf757_a && sleep 2400 && /usr/local/sbin/pistar-link ref069_c
50 19 * * 1 /usr/local/sbin/pistar-link ref020_a && sleep 2700 && /usr/local/sbin/pistar-link ref069_c

--
AF6VN
Dennis L Bieber
Post Reply