LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-16-2018, 12:03 PM   #1
MontyJ
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Rep: Reputation: Disabled
Question Boot Startup Script


Hola to All!

I have banged my head long enough!!

I am running Linux Mint 19. I need to run a simple script at boot time to invoke Mutt (simple mailer program) to send an email.

The script works when I run it manually. But when I put it into the "Startup Applications", it does not appear to run. I even added a delay of 100 seconds (max allowed by the Startup App) and it still did not send an email.

I then put a sleep command in the shell script for 300 seconds; still no email.

Here is my script as it stands now:
Code:
#!/bin/bash

sleep 300
echo "" | mutt -s "Email Test" -i /home/monty/myfile.txt myemail@hotmail.com
This does work if I run it manually using bash.

In the Startup Application setup, I have an entry that looks like this:
Code:
/bin/bash /home/monty/myfile.sh
Again, if I run that manually, with that exact statement, it runs and sends the email.

I put in the sleep command thinking perhaps Mutt needed services that were being delayed a bit on startup, but that didn't solve the problem.

Perhaps there is a log file with more details, but the few I looked at did not have anything I could identify with this script.

Ideas?

Thanks!
 
Old 07-16-2018, 12:43 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 5,284

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
When you run the program manually, your login environment is defined and knows where mutt is located.

When you run from the startup script, that may not be the case.

Try using /full/path/to/mutt in myfile.sh

[Note: this often is the case when scripts are run by cron, too. It's a good practice to always use absolute paths to everything when writing scripts that "others" will run.]
 
Old 07-16-2018, 12:55 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,685

Rep: Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658
In addition, Is your user configured to automatically log in?

Startup applications will run when you log in versus when the computer boots. If your user is automatically configured to login then it should be working. You can add a debug echo statement to your script to see if it is actually running.

date >> /home/monty/myfile.dat
 
Old 07-16-2018, 09:02 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hi MontyJ,

Welcome!

I think 'Startup Applications' requires the script be made into a .desktop file. Just open any .desktop file, change it to work with your script, delete what you don't need, and save it under a different name. You'll understand once you look inside one.
 
Old 07-16-2018, 09:18 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,685

Rep: Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658
The Startup Applications GUI wizard or whatever you want to call it automatically creates a .desktop file.

Obviously you can create one from scratch if desired.

Last edited by michaelk; 07-16-2018 at 09:19 PM.
 
Old 07-16-2018, 09:23 PM   #6
MontyJ
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Well, I have been trying all suggestions with no luck. But somehow I got it working at boot time by setting it up in /root with a 60 sec delay. It is working that way, but could never get anything to work via the startup applications setup method. I am using the "mail" command, not mutt. My "sent" file looks like this:

Quote:
From myemail@hotmail.com Mon Jul 16 16:42:32 2018
Date: Mon, 16 Jul 2018 16:42:32 -0700
From: root <myemail@hotmail.com>
To: myemail@hotmail.com
Subject: Email Test
Message-ID: <20180716234232.GA1957@monty-GA-990FXA-UD3>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.9.4 (2018-02-28)
Status: RO
Content-Length: 1
Lines: 1
Thanks for the .desktop suggestion. I will keep that in mind if I need to make another run at this.

Monty
 
Old 07-16-2018, 09:39 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,685

Rep: Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658
How did you setup the script up in /root? Out of curiosity what method did you finally use to run the script at boot? cron, rc.local, systemd

Last edited by michaelk; 07-16-2018 at 09:57 PM.
 
Old 07-16-2018, 09:54 PM   #8
MontyJ
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
How did you the script up in /root? Out of curiosity what method did you finally use to run the script at boot? cron, rc.local, systemd
I use rc.local. It looks like this after I applied a tip I found on the Internet:
Code:
touch /var/lock/subsys/local
/root/myfile.sh
I certainly don't understand 'why' it works this way, but since it does, I gotta go with it

Monty
 
Old 07-16-2018, 10:06 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,685

Rep: Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658Reputation: 3658
rc.local is a simple way to run scripts/commands at boot up without creating a startup script/service. rc.local is the last script to run before the desktop starts in the boot sequence.

As stated applications configured in Startup Applications are only started when the user logs in. If you do not have a user that automatically logs in it does not run at boot. While my simple script ran I did not try sending an email. Not running could of been caused by a mutt problem.
 
Old 07-17-2018, 10:10 AM   #10
MontyJ
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thumbs up

Just wanted to thank everyone for the very helpful comments re my noob questions.

They set me on the right track and to a solution that is working!

Monty
 
Old 12-19-2019, 12:13 PM   #11
pharmankur
LQ Newbie
 
Registered: Sep 2017
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by MontyJ View Post
Just wanted to thank everyone for the very helpful comments re my noob questions.

They set me on the right track and to a solution that is working!

Monty

I have exactly same issue ... Mutt script working when run manually but not when added in Startup Application (Linux Mint 19.1)

So what is the solution you headed to ?
 
Old 12-19-2019, 03:18 PM   #12
MontyJ
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Well, I don't use that process anymore, but when I got it working, it was working as I had posted: rc.local in root with a 60 second delay. Sorry, forgot the details as I moved on at some point and didn't need that process.
 
1 members found this post helpful.
Old 12-20-2019, 12:33 AM   #13
pharmankur
LQ Newbie
 
Registered: Sep 2017
Posts: 4

Rep: Reputation: Disabled
Thank You MontyJ for replying promptly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Script won't boot at startup Assomnia Linux - Software 10 06-30-2017 09:26 AM
LXer: How to automatically execute shell script at startup boot on systemd Linux LXer Syndicated Linux News 0 07-07-2016 11:21 AM
Delay startup script until 15 minutes after boot... ddenton Linux - Server 6 08-12-2008 09:16 PM
startup script at boot tigerflag Debian 8 03-31-2005 09:52 AM
how can I get/make a proper squid daemon startup script for boot time binkybuckle Debian 0 07-05-2003 08:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 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