LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 03-20-2017, 06:30 PM   #1
halek37
LQ Newbie
 
Registered: Mar 2017
Location: Loudon TN
Distribution: Debian
Posts: 24

Rep: Reputation: Disabled
Question Crontab - Detailed Questions


With all the help from this group I now have Crontab working, but have a few more detailed questions.

1. is there any limit to how many individual Crontabs can be entered at once?
Here is a 2 line example
Code:
30 8 * * * sh vida
30 9 * * * sh vidb
I would like to do 4 different crontabs a day for 5 days 20 Lines total

2. If those 20 lines are entered and then the Rpi is shut down overnight will all the data be retained. Or would it be required that the next 16 would have to be reentered after a reboot the following morning.

I have found that if i use a script as below that the FireFox line will open without any problem, apparently because the OMXplayer closes at the end of the video. However if the Firefox is run before the OMXplayer then the the FireFox must be shutdown before the OMXplayer can start.

Code:
#!/bin/bash
export DISPLAY=:0 && /usr/bin/omxplayer -o hdmi '/home/pi/Videos/Tue Compact.mp4'
 echo $(date) >> /home/pi/ek.log
firefox
3. Is there a way to send a shutdown from Crontab? Ctrl+C works in terminal.Or is there a workaround?

4. I have tried to get the email sent to my address at home. I added the following as the first line below the shebang in my script.
____ MAILTO=xyz@bellsouth.net
But I did not get any email.
Otherwise the script would be the same as in the second code box without the firefox

Thanks!
 
Old 03-21-2017, 10:16 AM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Quote:
1. is there any limit to how many individual Crontabs can be entered at once? ... I would like to do 4 different crontabs a day for 5 days 20 Lines total
Cron a service, crontab it's configuration file so no, though you may be eating up a lot of processor capacity running the individual services that cron triggers, the service itself isn't burdened by them.
Quote:
If those 20 lines are entered and then the Rpi is shut down overnight will all the data be retained
The crontab will remain persistent and the service will trigger the events listed therein. Any data gathered by those events is another question, however.
Quote:
3. Is there a way to send a shutdown from Crontab?
You could trigger a script that locates the PID (since you know the application name) and sends it a kill signal or a dbus trigger (a slightly different script instantiated by cron via the crontab).
Quote:
4. I have tried to get the email sent to my address at home. I added the following as the first line below the shebang in my script.
You'd probably have better luck sending the message to a local node, rather than your internet mail account. There can be a lot of reasons mail doesn't get passed along through the MTA/MTU infrastructure, first among them being none of them can resolve the originating domain (aka Spam).
Quote:
With all the help from this group I now have Crontab working,
Outstanding!
 
Old 03-21-2017, 11:01 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
crontab is a program used to maintain crontab files. No limit on how many you can enter. Depending on what version of cron is running there could be a limit on the total number of cron jobs but 20 is not a problem. No problem with shutting down the Pi but jobs will not automatically run if you start it back up after a scheduled time.

Many ways to kill a process. You can use pkill, killall, pgrep commands You can use pidof to find the PID of a running process.
 
Old 03-21-2017, 11:16 AM   #4
halek37
LQ Newbie
 
Registered: Mar 2017
Location: Loudon TN
Distribution: Debian
Posts: 24

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by halek37 View Post
With all the help from this group I now have Crontab working, but have a few more detailed questions.
1. is there any limit to how many individual Crontabs can be entered at once?
Here is a 2 line example
Code:
30 8 * * * sh vida
30 9 * * * sh vidb
I would like to do 4 different crontabs a day for 5 days 20 Lines total

2. If those 20 lines are entered and then the Rpi is shut down overnight will all the data be retained. Or would it be required that the next 16 would have to be reentered after a reboot the following morning.

I have found that if i use a script as below that the FireFox line will open without any problem, apparently because the OMXplayer closes at the end of the video. However if the Firefox is run before the OMXplayer then the the FireFox must be shutdown before the OMXplayer can start.

Code:
#!/bin/bash
export DISPLAY=:0 && /usr/bin/omxplayer -o hdmi '/home/pi/Videos/Tue Compact.mp4'
 echo $(date) >> /home/pi/ek.log
firefox
3. Is there a way to send a shutdown from Crontab? Ctrl+C works in terminal.Or is there a workaround?

4. I have tried to get the email sent to my address at home. I added the following as the first line below the shebang in my script.
____ MAILTO=xyz@bellsouth.net
But I did not get any email.
Otherwise the script would be the same as in the second code box without the firefox

Thanks!
 
Old 03-21-2017, 11:22 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
Why did you copy your original post? Did you read the replies?

What do you not understand?

Last edited by michaelk; 03-21-2017 at 11:34 AM.
 
Old 03-21-2017, 11:51 AM   #6
halek37
LQ Newbie
 
Registered: Mar 2017
Location: Loudon TN
Distribution: Debian
Posts: 24

Original Poster
Rep: Reputation: Disabled
Sorry

Quote:
Originally Posted by michaelk View Post
Why did you copy your original post? Did you read the replies?

What do you not understand?
Sorry I did not intend to copy my original Post.

I did read them all but was trying to understand How to use the Quote Box.
Thanks again, I think I understand what was sent, with a small exception that I was going to experiment with.

If I use the killall in a script in crontab to kill the firefox before running the next omxplayer. Would that kill the crontab also?
 
Old 03-21-2017, 12:20 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
No it will not.
 
Old 03-21-2017, 02:27 PM   #8
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
If you prefaced your omxplayer script with a line like
(treat the following as pseudocode)
kill $(ps aux | grep [f]irefox | awk '{print $2}') 9 && sleep 10

and if you only have a single instance of firefox running at that time, it should zap it prior to omxplayer starting up

Quote:
Sorry I did not intend to copy my original Post.
no worries

Hope that helps

Last edited by dijetlo; 03-21-2017 at 02:30 PM.
 
Old 03-21-2017, 02:37 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
Code:
$(ps aux | grep [f]irefox | awk '{print $2}')
You can simply a bit...
Code:
$(pidof firefox)
 
1 members found this post helpful.
Old 03-21-2017, 02:43 PM   #10
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled


Doesn't work on Unix systems and therefor, not Posix compliant ? ( I don't have a Solaris node handy at the moment, I'm just guessing here...)

 
Old 03-21-2017, 02:57 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
pidof is actually a link to killall5. It's been a long time since I've played with Unix...
 
Old 03-21-2017, 03:46 PM   #12
halek37
LQ Newbie
 
Registered: Mar 2017
Location: Loudon TN
Distribution: Debian
Posts: 24

Original Poster
Rep: Reputation: Disabled
Everytime I feel like I see the light at the end of the tunnel I find that it really is just a hole before starting the next tunnel. but THANK You all for your help!

I will include 2 scripts That I ran with crontab on 2 lines a minute apart.
The first is the script that I setup to run my video and when it was finished open firefox. But I found that that needed a way to shut firefox down.
My solution one
Code:
#vidb To play video from a script
#
#!/bin/bash
export DISPLAY=:0 && /usr/bin/omxplayer -o hdmi '/home/pi/Videos/Tue Compact.mp4'
 echo 'Ran vidb' >>  /home/pi/ek.log
 echo $(date) >> /home/pi/ek.log

firefox
That worked just great, firefox went away and my video played but when it finished firefox opened again. So I tried addind the second killall, but had no effect.
Code:
#vidd3 To play video from a script with killall
#!/bin/bash
killall -eq firefox
export DISPLAY=:0 && /usr/bin/omxplayer -o hdmi '/home/pi/Videos/Tue Compact.mp4'
 echo 'ran vidd3' >>  /home/pi/ek.log
 echo $(date) >> /home/pi/ek.log
killall -eq firefox
I have not tried your latest sugestions yet.
Is the problem somehow related to the display function?
 
  


Reply

Tags
crontab, rpi



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] crontab does not reread the crontab file upon modification of the latter. stf92 Slackware 4 08-01-2015 06:12 PM
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM
DIff B/w Crontab -l & crontab -e Tareq9959 Linux - Newbie 2 05-14-2013 08:27 AM
Questions regarding crontab ubuntunewby Linux - Newbie 8 06-26-2011 11:23 AM
Detailed questions about UUID's Cage47 Linux - Hardware 6 01-29-2010 09:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 06:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration