You are not logged in.
I have a little script called "musor", which has to be run every day at 00:01 hour. I installed the cronie package, and I added the job into the crontab.
sudo crontab -lshows:
0 1 * * * /home/walaki/dl/musorits attributes are the following: "-rwxr-xr-x 1"
I had run both: "sudo systemctl enable cronie"
and "sudo systemctl start cronie"
The script doesn't start at all, because it would make a log file in its own directory (I programmed it with full path name of the log file). When I run the script by hand it works of course. What can be the problem?
Offline
What's in the script?
Offline
It's a Ruby script, it works, I tested.
Offline
Sigh.
Why ask for help if you aren't willing to cooperate? https://wiki.archlinux.org/index.php/Fo … way_Street
Offline
Because I don't speak english very well. I have to use a dictionary to make my sentences, and it is a bit fumbling. So it would be difficult for me to answer other's questions. I think I am an absolute beginner, I am using linux not more then 1.5 years.
Last edited by Bailando (2014-06-18 22:44:24)
Offline
@Bailando, jasonwryan isn't asking you to answer other users' questions but only to cooperate with those trying to answer your question by providing the information requested. That is, please post the content of the script rather than just telling us that you are sure the script isn't the problem. (If you are really sure that isn't the problem, you presumably know enough to answer your own question.) 'Two-way' can mean asking smart questions - it doesn't just mean providing smart answers. There is nothing more frustrating than trying to help somebody who refuses to provide the information you need to solve their problem!
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
If the script works from the command line there is no reason to suspect the script. Who cares what's in it?
Bailando
Your crontab line wil only execute the script at 01:00 nightly. Is that your intention? If it is, please post the output of 'sudo systemctl status cronie'.
EDIT: I missed that the timing is intentional when I first read your post. I'd also be interested in the contents of /var/log/crond.log
Last edited by samiam (2014-06-18 23:05:14)
Offline
If the script works from the command line there is no reason to suspect the script. Who cares what's in it?
Because the environment it runs in when executed by the user is very different to that under cron. It is a common error when people first start using cron and one of the first things to test.
Offline
Okay, this is my script, maybe it helps:
#!/usr/bin/ruby
# encoding: utf-8
require 'watir-webdriver'
require 'pry'
reklam=["http://keresztenytars.net","http://premium-leechers.blogspot.hu"]
fname="/home/walaki/util/radiomusor-blogger.txt"
b = Watir::Browser.new :phantomjs
if ARGV.length==0 then
date_today=Time.now.to_s.split(" ")[0]
else
date_today=ARGV[0]
end
url="http://hangtar.radio.hu/kossuth#!#"+date_today
datepart=date_today.gsub("-","")
dow=Date.parse(date_today).strftime("%A")
case dow
when /monday/i
nap="Hétfő"
when /tuesday/i
nap="Kedd"
when /wednesday/i
nap="Szerda"
when /thursday/i
nap="Csütörtök"
when /friday/i
nap="Péntek"
when /saturday/i
nap="Szombat"
when /sunday/i
nap="Vasárnap"
end
puts url
puts nap
puts datepart
b.goto url
b.links(:text=>"Részletes műsor")[0].click
sleep 6
#html="";b.divs(:class=>"musorelem sclick").each{|d| d.click rescue nil;html+=b.html}
html=b.html
tc=html.scan(/class\=\"me_idopont.*?\<span\>(.*?)\<\/span\>.*?\<div.*?class\=\"me_cim.*?\<span\>(.*?)\<\/span\>.*?\<div.*?class\=\"me_leiras.*?\>(.*?)\<\/div\>/m).flatten
h={};for i in 0..(tc.length-1)/3; h.merge!(tc[i*3]=>[tc[i*3+1],tc[i*3+2]]);end
open(fname, 'w') { |f|
f.puts "<div class='post-body entry-content' itemprop='articleBody'>"
f.puts "<b>"+nap+"</b><br>"
h.each do |k,v|
#line="<a href=http://stream001.radio.hu:443/stream/"+datepart+"_"+k.gsub(":","")+"00_1.mp3>"+k+" "+v[0]+"</a><br><p style='margin: 0px 0px 0px 15px; text-align:justify; line-height:10px'><small>"+v[1].gsub("<br>","\n")+"</small></p>"
line="<a href=http://stream001.radio.hu:443/stream/#{datepart}_#{k.gsub(":","")}00_1.mp3>#{k}</a> <a href='#{reklam.sample(1).first}' target=_blank>#{v[0]}</a><br><p style='margin: 0px 0px 0px 15px; text-align:justify; line-height:10px'><small>#{v[1].gsub("<br>","\n")}</small></p>"
#binding.pry
#puts line
f.puts line
end
f.puts "</div>"
}
var='cp ~/.config/googlecl/luckyluke-config ~/.config/googlecl/config; google blogger post --blog="Kossuth Radio Budapest" --tags="'+nap+'" --title="'+date_today+', '+nap+'" --src=/home/walaki/util/radiomusor-blogger.txt'
system varUnfortunately "sudo systemctl status cronie" doesn't shows any output. Maybe this is the problem?
Last edited by Bailando (2014-06-18 23:10:02)
Offline
Dang it. I really wanted it to not be the script ![]()
Add this as the first line of your script:
#!/usr/bin/rubyEDIT:
And yes, status should return something like this:
sudo systemctl status cronie
* cronie.service - Periodic Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/cronie.service; enabled)
Active: active (running) since Wed 2014-06-18 18:02:10 CDT; 5min ago
Main PID: 26436 (crond)
CGroup: /system.slice/cronie.service
`-26436 /usr/bin/crond -n
Jun 18 18:02:10 megalodon crond[26436]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 21% if used.)
Jun 18 18:02:10 megalodon crond[26436]: (CRON) INFO (running with inotify support)
Jun 18 18:04:01 megalodon crond[26436]: (root) CAN'T OPEN (/etc/crontab): No such file or directory
Jun 18 18:04:01 megalodon crond[27035]: pam_unix(crond:session): session opened for user root by (uid=0)What does 'ps -ef | grep cron' return? You should see something like this:
ps -ef | grep cron
root 26436 1 0 18:02 ? 00:00:00 /usr/bin/crond -nLast edited by samiam (2014-06-18 23:10:12)
Offline
Sorry, the shebang line _is_ in my script, I only forgot to copy paste those two lines.
Offline
"ps -ef | grep cron" shows:
root 142 1 0 Jun11 ? 00:00:02 /usr/bin/crond -n
walaki 3870 6551 0 01:13 pts/5 00:00:00 grep cron"sudo systemctl status cronie" shows:
● cronie.service - Periodic Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/cronie.service; enabled)
Active: active (running) since Wed 2014-06-11 18:39:53 CEST; 1 weeks 0 days ago
Main PID: 142 (crond)
CGroup: /system.slice/cronie.service
└─142 /usr/bin/crond -n
Jun 19 00:01:02 philip anacron[1085]: Anacron started on 2014-06-19
Jun 19 01:00:01 philip crond[3152]: pam_unix(crond:session): session opene...0)
Jun 19 01:00:01 philip CROND[3153]: (root) CMD (/home/walaki/dl/musor-blogger)
Jun 19 01:00:03 philip CROND[3152]: (root) CMDOUT (/usr/lib/ruby/2.1.0/rub...))
Jun 19 01:00:03 philip CROND[3152]: (root) CMDOUT ( from /usr/lib/r...')
Jun 19 01:00:03 philip CROND[3152]: (root) CMDOUT ( from /home/wala...')
Jun 19 01:00:03 philip CROND[3152]: pam_unix(crond:session): session close...ot
Jun 19 01:01:01 philip crond[3185]: pam_unix(crond:session): session opene...0)
Jun 19 01:01:01 philip CROND[3186]: (root) CMD (run-parts /etc/cron.hourly)
Jun 19 01:01:01 philip anacron[3191]: Anacron started on 2014-06-19
Hint: Some lines were ellipsized, use -l to show in full./var/log doesn't contain anything related to cronie.
Last edited by Bailando (2014-06-18 23:21:07)
Offline
I'm confused about whose crontab you're using. You seem to be adding the script to root's crontab using sudo but in your script you use ~ as if it refers to your user's home directory. But if the script is executed by root, that will refer to /root/ and not to /home/walaki/ or whatever. Have you tried adding it to your user crontab instead?
Last edited by cfr (2014-06-18 23:29:54)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
Because I run the cronie service on my VPS.
Oh, I see. Maybe that is the problem, I added to crontab as root.
Last edited by Bailando (2014-06-18 23:35:02)
Offline
Try adding it without sudo so that it is added to your user crontab and runs as you.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
Thx for all contributors, it works now. I simply had to install my crontab job as a regular user and not as root...
Offline