Script not running through cronjob?
What I'm trying to achieve is for cron to run a command every half hour, which runs a script located in /home/user/.scripts/ creatively called script. This script, as per my previous thread checks if a program is running, if it isn't, runs it.
In /home/user/.scripts/script ls -l shows Code:
-rwxr-xr-x 1 user user 85 Jun 29 19:40 script crontab -l shows: Code:
*/30 * * * * sh /home/user/.scripts/script And sudo cat /var/log/syslog shows: Code:
Jun 30 08:00:01 desktop /USR/SBIN/CRON[7660]: (user) CMD (sh /home/user/.scripts/script) The script itself works fine if I run it from a command line. I can see that the cronjob is being run. But it isn't working. How do I get insight into what is occurring? |
Can you post the script that is being run?
|
Of course!
Code:
#!/bin/bash |
That piece of code doesn't look correct. Try this instead:
Code:
#!/bin/bash |
Two items -
1. you assume that "deluge" and "pkill" (or pgrep) is in the search path for the program. It won't work if they aren't. 2. (this is a bit of a nit and can be ignored) you assume that the process named "deluge" is actually the one you want... A process can have any name it wants - If you make a symbolic link to "ls" and name it deluge, then, when run, ls will be identified as "deluge". Have you checked your local mail? cron will mail any output from a job to the local mail account, so any errors generated by the script will be mailed to you. One more thing - does "deluge" require a GUI? If it does, then it will not necessarily be available - you might be logged out, and if you log in it may not be able to get the correct access key as it would have been cut off when you logged out... |
Quote:
Thanks for the idea. Unfortunately the script doesn't work and I don't know what you mean by 'the full path to the executable'. I type in deluge in the command line and it runs. jpollard, I'm afraid I don't really understand what you've said. I didn't know I had local mail either. It does have a GUI, but the computer is always logged in. I just want my computer to start deluge at boot, which sometimes it does, other times it doesn't. This is why I thought this script which runs every half hour would fix that. Check it's running, if not, start it. |
Just a random idea I've just had, but can't find how to do it at the moment. If I set the script to start on boot, the I could have the script loop itself infinitely every 30 minutes.
Code:
#!/bin/bash Thanks |
Quote:
You need to find out why deluge behaves this way. Putting a script in place that starts deluge if it isn't running makes the problem harder to trouble-shoot: Is deluge not starting or is the script faulty or possibly both. Once you figure out why deluge behaves the way it does during boot you can tackle that and your problem is solved. If deluge does start a gui: You cannot use cron to accomplish this (as already stated by jpollard) and I doubt it will start during the boot process. EDIT: As a workaround you might use the ability of Desktop Managers (gnome/kde/etc) to start a program when you log in. |
How do I tell why MATE appears to have forgotten to start Deluge?
Quote:
|
Quote:
|
I tried adding the script to /etc/init.d/ which didn't work, and then I added it to /etc/network/if-up.d/ and now my computer won't boot. If I manage to fix this, please can someone just tell me how I can get the computer to run this script at startup in a how to style? I'm quite sick of guessing my way through it and to be honest it was inevitable that eventually I was going to break the computer.
Thanks |
I just had a look at the deluge web pages and noticed that this bittorrent-client has 2 parts: A daemon (deluged) and a user interface (deluge).
The part you are talking about is the user interface, which is a graphical interface. As stated before by jpollard and me: You cannot start this at boot or by using cron. In post #6 you tell us that deluge sometimes works and sometimes it doesn't. I don't think a script will solve this problem, you'll need to figure out why deluge (and/or deluged) acts this way. I suspect that something is wrong with the setup and that is why you are having problems. I cannot point you to anything specific (I have no experience whatsoever with bittorrent clients in general and deluge in specific). Do have a look at the documentation that is present on the deluge web site and maybe the forum on that site might be able to help you. |
I think maybe we are using the same words to describe different things. The computer that this is running on automatically logs in for me, and therefore I want this to run once the computer is booted and therefore logged on.
If I press the power button on my computer, after it does it's thing, with no input from anyone, it will wait on the desktop, logged in ready for me to go. I open a terminal and type: Code:
sh /home/user/.scripts/script Is this still an impossibility even with this further explanation? |
As I mentioned earlier:
Quote:
|
Quote:
Code:
$ which deluge Quote:
Code:
$ mail Quote:
|
All times are GMT -5. The time now is 07:04 PM. |