LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Mint
User Name
Password
Linux Mint This forum is for the discussion of Linux Mint.

Notices


Reply
  Search this Thread
Old 11-15-2016, 03:07 PM   #16
lamic
Member
 
Registered: Jan 2013
Posts: 37

Original Poster
Rep: Reputation: Disabled

Adding more info on the cron service
Code:
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-11-14 21:16:36 CST; 17h ago
     Docs: man:cron(8)
 Main PID: 862 (cron)
   CGroup: /system.slice/cron.service
           └─862 /usr/sbin/cron -f

Nov 14 21:16:36 mist-vm cron[862]: (CRON) INFO (pidfile fd = 3)
Nov 14 21:16:36 mist-vm cron[862]: (CRON) INFO (Running @reboot jobs)
Nov 14 21:16:36 mist-vm CRON[875]: pam_unix(cron:session): session opened for user root by (uid=0)
Nov 14 21:16:36 mist-vm CRON[876]: pam_unix(cron:session): session opened for user root by (uid=0)
Nov 14 21:16:36 mist-vm CRON[912]: (root) CMD (/home/mist/Documents/test.sh)
Nov 14 21:16:36 mist-vm CRON[913]: (root) CMD (/home/mist/Documents/foo.sh > /home/mist/Documents/log.txt)
Nov 14 21:16:36 mist-vm CRON[875]: (CRON) info (No MTA installed, discarding output)
Nov 14 21:16:36 mist-vm CRON[875]: pam_unix(cron:session): session closed for user root
Nov 14 21:16:36 mist-vm CRON[876]: (CRON) info (No MTA installed, discarding output)
Nov 14 21:16:36 mist-vm CRON[876]: pam_unix(cron:session): session closed for user root
 
Old 11-15-2016, 03:58 PM   #17
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Does the file "home/mist/Documents/log.txt" have anything (or even exist)?
 
Old 11-15-2016, 04:00 PM   #18
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Quote:
Nov 14 21:16:36 mist-vm cron[862]: (CRON) INFO (Running @reboot jobs)
Nov 14 21:16:36 mist-vm CRON[912]: (root) CMD (/home/mist/Documents/test.sh)
So it appears that the script is running now.
 
Old 11-15-2016, 04:26 PM   #19
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by michaelk View Post
So it appears that the script is running now.
Actually, I think it means it is trying to start - whether it is running depends on the output.

any error/status messages were discarded.
 
Old 11-15-2016, 05:23 PM   #20
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Quote:
Nov 15 16:41:36 server CRON[877]: (root) CMD (/home/user/test.sh 40 &)
Possibly, I just created a Mint VM and the script works with the same output.
 
Old 11-15-2016, 05:50 PM   #21
lamic
Member
 
Registered: Jan 2013
Posts: 37

Original Poster
Rep: Reputation: Disabled
@michaelk When you do
Code:
 ps -ef | grep test
Do you see the process running ?

@jpollard the file showed in Documents, but only after i cycled the service.

Also, i was messing around with rc.local and after i cycled the service the script was running. Now, im wondering if its caused by run levels. Cron is set for lv 2/3/4/5 and rc.local is set for 2/3/4/5 and i added 6 and S
 
Old 11-15-2016, 06:26 PM   #22
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Quote:
root 903 1 0 18:03 ? 00:00:00 /bin/bash /home/user/test.sh 40
Yes, however I also increased the run time to 200 seconds. Not sure how long it takes the VM to start but 120 seconds may not of given me enough time to verify the script was running.

Starting cron or rc.local in runlevel 6 will not do anything. I also just tested the script by running it from rc.local and it also worked. I did not have to change or start any services from whatever Mint sets as default.
 
1 members found this post helpful.
Old 11-15-2016, 07:04 PM   #23
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by michaelk View Post
Yes, however I also increased the run time to 200 seconds. Not sure how long it takes the VM to start but 120 seconds may not of given me enough time to verify the script was running.
adding delays may help... but you can't be sure of how long you have to wait. What works at one time may not work the next.
Quote:
Starting cron or rc.local in runlevel 6 will not do anything. I also just tested the script by running it from rc.local and it also worked. I did not have to change or start any services from whatever Mint sets as default.
Adding "run levels" won't make any difference. systemd only fakes the run levels - they run as soon as the system thinks the network is "ready", not necessarily when the network is usable (that requires an additional service - "NetworkManager-wait-online"). Along with that are any other services being started at the same time.
 
1 members found this post helpful.
Old 11-15-2016, 07:16 PM   #24
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Not sure why the network being ready or not affects either cron, rc.local or the test script in this circumstance. Or am I missing something.
 
Old 11-15-2016, 07:26 PM   #25
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by michaelk View Post
Not sure why the network being ready or not affects either cron, rc.local or the test script in this circumstance. Or am I missing something.
It all depends on the environment the script is running in and what it needs. If the script needs database access, automounting, or something remote - it can fail.

Even now, local mounts may be done in some parallel order - which may cause other failures (which may be why the sleep time suddenly worked, where it didn't before). Another thing that can change the order is if you us ypbind. If this service is enabled, then suddenly the crond will wait until after it is active, which would appear totally unrelated... (it isn't, as systemd assumes that the user identities used by crond must be taken from a ypbind service, or maybe it is assuming NFS must be being used...).

This is why adding things to systemd configurations is tricky - sometimes it works, sometimes not, adding a delay works, sometimes not. The problem is the complexity of the systemd dependency network.

The present script SHOULD work (even without the time delays)... but like I said, the run levels run anytime after the network is "ready", but that doesn't mean other services are ready if the script is modified to use one of them.

Last edited by jpollard; 11-15-2016 at 07:33 PM.
 
Old 11-15-2016, 07:34 PM   #26
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
True. With the OP'S simple script it shouldn't matter. Not sure what the OP changed from default so that neither cron or rc.local do not work.
 
Old 11-15-2016, 10:56 PM   #27
lamic
Member
 
Registered: Jan 2013
Posts: 37

Original Poster
Rep: Reputation: Disabled
@michaelk how do you initiate the script? I have also created VM with Mint 18, and it doesn't work. I havent changed any settings. Im out of ideas now.
 
Old 11-16-2016, 05:17 AM   #28
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
I tested your script using both cron via @reboot and rc.local as described above. I'm not sure why your VM isn't working.
 
Old 11-16-2016, 05:23 AM   #29
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
the first thing I would try is to redirect stdout/stderr of crontab entry into a local file.
next, I would remove the redirection to /dev/null in test.sh
also you can do a touch "/tmp/here_we_are" in the crontab (or similar) just to check if that works
 
Old 11-16-2016, 05:32 AM   #30
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Good point. The OP did create a foo.sh script that wrote to a log.txt file but did not state if tested in the VM.
 
  


Reply



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
Starting Script on boot - what am I doing wrong? pazu Linux - General 4 02-19-2015 05:20 AM
starting a programme from boot script in Etch knobby67 Debian 10 02-05-2008 03:38 AM
Starting a daemon in an init.d bootup script without root being the owner BobTheSlob Linux - General 1 09-19-2007 11:19 AM
starting the script at boot time hudy_rob Mandriva 4 12-09-2004 10:29 AM
starting a script on boot jax8 Linux - Newbie 1 03-19-2004 10:38 PM

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

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