LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-18-2018, 05:43 AM   #1
SteveRobbins
LQ Newbie
 
Registered: Sep 2008
Posts: 5

Rep: Reputation: 0
Problems using sakis3g GSM modem script from cron


I am building a small unit, based on a Raspberry Pi, to control central heating using a fairly complicated schedule in a building with no wired Internet access.

I am using the Sakis3g script to control a USB GSM dongle (O2, but actually a Huawei dongle).

When I use the sakis3g script standalone, it works fine (everything done as root):

root@raspberrypi:~# ./sakis3g connect APN=m-bb.o2.co.uk
E160 connected to O2 - UK (23410).
root@raspberrypi:~#

But - when I try to run the sakis3g command from within a script executed from cron, it simply doesn't do anything (it just executes for 2-3 seconds and that's it - nothing happens).

Output from /var/log/syslog:

Jan 18 11:26:01 raspberrypi CRON[5302]: (root) CMD (/root/networkon.sh)
Jan 18 11:26:04 raspberrypi CRON[5298]: (CRON) info (No MTA installed, discarding output)

The script which is run from cron:

root@raspberrypi:~# cat /root/networkon.sh
#! /bin/sh

./sakis3g connect APN=m-bb.o2.co.uk
root@raspberrypi:~#

The root crontab entry:

# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
21 * * * * /root/networkon.sh

Anyone any ideas please??
 
Old 01-18-2018, 07:31 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Replace this part of your script
Code:
./sakis3g
with the full path to sakis3g
 
1 members found this post helpful.
Old 01-18-2018, 02:52 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ it might help, but it might not.
i had some experience with sakis3g some time ago.
i came to the conclusion that it's a horrible mish-mash of scripts cludged together with hotsnot. no idea how it will behave when called form cron (i did indeed have a similar problem with it).
it's good because ~10years ago it was able to recognize simply everything, and connect.
but nowadays, i don't know if it's even maintained anymore.
if you can, don't use it.
 
Old 01-18-2018, 03:06 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Also cron is to be treated like a user. It has to have access to all that you have when your run this script.
 
Old 01-19-2018, 03:05 AM   #5
SteveRobbins
LQ Newbie
 
Registered: Sep 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks, TenTenths, in fact I did have the full path to sakis3g (the line in the post was a cut-and-paste error).

You are right, Ondoho - it is a terrible mish-mash - but in fairness it DID download and immediately work with my modem/carrier combination (O2) and I had it running standalone within 5 minutes, it just wouldn't work from cron.

BUT - I have now got to the bottom of it - after much digging around!

For some bizarre reason I don't understand (because the whole thing is running as root anyway) one has to add the "--sudo" line to the command before it will work from cron, i.e.

/root/sakis3g --sudo connect APN=m-bb.o2.co.uk

and now all is working!

Thanks for your input
 
Old 01-19-2018, 02:48 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Cron is not root.
 
  


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
Need a bandwith manager for Sakis3g script karnal Linux - Newbie 2 02-01-2012 04:39 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
script problems for cron ABL Linux - Software 3 12-16-2007 04:43 AM
GSM modem the_imax Linux - Networking 0 09-21-2004 05:20 AM
gsm modem noODle Linux - General 1 03-27-2002 07:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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