learning cron command

Help with D-Star related issues
AK7AN
Posts: 75
Joined: Fri Jun 14, 2019 2:17 am

Re: learning cron command

Post by AK7AN »

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
[/quote]
[/quote]

So this added to the "system cron" will make changes to connections and return to the stated reflector?
I could just edit this with changes in date, time, reflectors, etc to suit what I would like. Just wanting to verify it works as intended before implementing.
Thanks
Ed
AK7AN
AF6VN
Posts: 821
Joined: Fri Jul 20, 2018 1:15 am

Re: learning cron command

Post by AF6VN »

Your edits to the quoted text have messed it up greatly but...

The key point is that what YOU added the crontab is MISSING the user account for those actions.

The account comes between the end of the schedule fields and the start of the command field.

So stuff "root" into each of those lines.

--
AF6VN
Dennis L Bieber
AK7AN
Posts: 75
Joined: Fri Jun 14, 2019 2:17 am

Re: learning cron command

Post by AK7AN »

Took some trial and error but this works.. "man 5 crontab" is a must read if you want to get it right,

Code: Select all

# /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                                             
29 19   * * 2   root    /usr/local/sbin/pistar-link xrf303_d && sleep 3600 --&& /usr/local/sbin/pistar-link xrf277_d
#55 13   * * 1   root    /usr/local/sbin/pistar-link ref001_c && sleep 300 --&& /usr/local/sbin/pistar-link xrf277_d

Don't forget to leave a empty line at the end of the file, that was my hangup until I read the man 5 file.
The bottom line was my test line until I got it right, just hashtag to ignore.
XRF277 D is a reflector that I host on my server.. feel free to use..
Thanks to those that share their knowledge and expertise on this forum, I have learned a ton since I started playing with Pi-Star.
73
Ed
AK7AN
n2kto
Posts: 10
Joined: Sat Aug 17, 2019 12:01 pm

Re: learning cron command

Post by n2kto »

I think I have complied to the format now including the "root" in the sentence. I have spaces before and after the "root". I added a test line at the bottom to allow me to see if pi-star would change to the reflectors specified. I applied the lines to pi-star and there still seems to be an error.
would it be possible that you show an exact example of what I should type to get the correct results. I have 0 experience with Linux command line. Spaces do not show up very clearly and may be the issue.
I am using the config/expert/System cron page to make all edits and hitting the apply tab. I am not using ssh. Do I need to reboot the system after making edits?
Here is the exact script I have running on my pi-star image.

# /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
# m h dom mon dow command
# Young Operators Digital Voice Net Control Danielle KE8JNU
59 20 * * 0 root /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 root /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 root /usr/local/sbin/pistar-link xrf757_a && sleep 3600 && /usr/local/sbin/pistar-link ref069_c
# Test of cron job
44 11 * * 2 root /usr/local/sbin/pistar-link xrf757_a && sleep 120 && /usr/local/sbin/pistar-link ref069_c

Thanks so much for your help as this script will allow several people that use my high power hot spot to listen to the nets weekly.
Dave Hubbell N2KTO
n2kto
Posts: 10
Joined: Sat Aug 17, 2019 12:01 pm

Re: learning cron command

Post by n2kto »

Could the word sudo lacking be my issue?
n2kto
Posts: 10
Joined: Sat Aug 17, 2019 12:01 pm

Re: learning cron command

Post by n2kto »

Ed,
It works!!!!!!!!!!!!!!!!!!!!!!!!!!! It was the line at the very end that I did not add!!!!!!!!!!!
Thank you very much for helping me get this right. I am normally on REF069C or REF020A.

Now on to tackle how to make announcements.
Thanks again for the help.
Dave
AF6VN
Posts: 821
Joined: Fri Jul 20, 2018 1:15 am

Re: learning cron command

Post by AF6VN »

n2kto wrote: Tue Feb 18, 2020 4:59 pm Could the word sudo lacking be my issue?
No... By specifying the user as "root" the rest of the line already runs with root privileges. The system crontab can run stuff as any user, whereas editing user account crontabs run as that user, and only as that user.

--
AF6VN
Dennis L Bieber
AK7AN
Posts: 75
Joined: Fri Jun 14, 2019 2:17 am

Re: learning cron command

Post by AK7AN »

n2kto wrote: Tue Feb 18, 2020 5:10 pm Ed,
It works!!!!!!!!!!!!!!!!!!!!!!!!!!! It was the line at the very end that I did not add!!!!!!!!!!!
Thank you very much for helping me get this right. I am normally on REF069C or REF020A.

Now on to tackle how to make announcements.
Thanks again for the help.
Dave
Dave
Glad that it worked..
Nice to talk to you yesterday too, My setups linked up just fine to the net that I wanted last nite and returned home at the predetermined time. This is quite fun when you can get things to work as you want them to.
What type of announcements are you working on?
73
Ed
AK7AN
n2kto
Posts: 10
Joined: Sat Aug 17, 2019 12:01 pm

Re: learning cron command

Post by n2kto »

I belong to a Search and Rescue team and was hoping that I might add a voice message like "The K9RRD Search and Rescue net will begin in 10 minutes on XRF020H this high power hotspot will disconnect from REF020A and reconnect to XRF020H for 45 minutes. The net will be a directed net. Net controller today will be N2KTO, Dave. Only active members of the Ramapo Rescue Dog Association will be recognized but all are welcome to listen. The K9RRD net will be backed up with D-RATS for sharing information and callsign check in information.

Also would like to be able to make up Weather and Disaster messages.
There was a utility in IRCDDB along time ago that would allow this but can't seem to remember how.
AK7AN
Posts: 75
Joined: Fri Jun 14, 2019 2:17 am

Re: learning cron command

Post by AK7AN »

Let me know if you can accomplish the announcement. That would be a nice function.
73
Ed
AK7AN
Post Reply