You are not logged in.

#1 2012-06-05 12:42:10

mfaridi
Member
Registered: 2010-12-15
Posts: 192

I have ADSL connection and I want at 8 morning my arch linux stop

I have lnksys ADSL modem in home and my Arch linux connect to ADSL modem by network cable and I use Arch linux for download some files in night . I want my arch linux stop download files at eight o'clock in morning how I can do this with arch linux I want it start at 24 o'clock and stop at 8 oclock


I at 8 o'clock in morning and I wat it start dowload at 24 . how I can do this with Arch linux

Offline

#2 2012-06-05 14:51:24

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

look into cron jobs


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2012-06-05 23:33:34

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Sorry all , for my bad english , I can not describe very good my problem , I want way to stop networking at 8 morning , for examplw with crontab or something else , or use some script to stop networking , when netwoking is stop so  my Arch linux can not download files from internet , I use wget or transmission for download files , if I can find way to stop download files at 8 morning it is good and great

Offline

#4 2012-06-06 00:27:13

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Did you look at the wiki page for cron:

https://wiki.archlinux.org/index.php/Cron

Depending what tool (daemon) you use for networking, you could just stop it like:

rc.d stop network

Offline

#5 2012-06-06 08:14:49

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

anonymous_user wrote:

Did you look at the wiki page for cron:

https://wiki.archlinux.org/index.php/Cron

Depending what tool (daemon) you use for networking, you could just stop it like:

rc.d stop network

thanks, I wish I do this with crontab,  I want something like crontab do this for me,  I want networking stop when I am not in home at eight morning

Offline

#6 2012-06-06 08:56:25

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Transmission do have scheduling which you can set to 0 for a certain time span of the day. With a remote client like transmission-remote-gtk you can of course do it remotely.

Offline

#7 2012-06-06 15:03:46

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

mfaridi wrote:

thanks, I wish I do this with crontab,  I want something like crontab do this for me,  I want networking stop when I am not in home at eight morning

Yeah, I think everyone's understood what you want to do. We have also provided solutions to you. But you are the one who's gonna have to decide which solution to use depending on your task and implement it.

crontab is well documented
if its torrents you want to block, your torrent client should be well documented. (if not, use a client that is - swanson mentioned transmission, which is what you could use.)

Arch is DIY, there is no spoon feeding here. Unless you try something and it doesn't work, this thread for all purposes is solved, IMO.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#8 2012-06-06 15:38:18

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: I have ADSL connection and I want at 8 morning my arch linux stop

This should get you started.

Here are the lines from my crontab that starts transmissiond at 23:00 and stops at 09:00 (data usage doesn't count towards the monthly limit)

0 23 * * * transmission-remote -t all -s > /dev/null
0 9  * * * transmission-remote -t all -S > /dev/null
10,30,50 0-6,23 * * * /home/paul/alldone

"alldone" shuts down my laptop if all torrents are 100% downloaded

#!/bin/bash
# run by my crontab
#
# shutdown laptop if all torrents have completed downloading

# check for latest torrents

castget -1 -q

# don't shut down if logged in

if (( `users | grep -c paul` > 0 )); then
 exit
fi

# exit if no torrent has been fetched as it hasn't even started downloading yet

if (( `find /home/paul/Save | grep -c torrent.added` == 0 )); then
 exit
fi

# shutdown if all torrents are "100%"

if (( `transmission-remote -l |grep " ..%" -c` == 0 )) ; then
 sudo /etc/rc.d/transmissiond stop
 touch torrentdone
 sudo /sbin/halt
fi

Offline

#9 2012-06-06 15:43:27

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

so much for my comment about spoon-feeding.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#10 2012-06-08 16:12:57

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

I use put this line in my crontab

 35 20   *   /sbin/shutdown -h -P -t secs now 

but this command dose not work when I run this command

 tail -f /var/log/crond.log 

I see this

Jun  9 20:44:01 localhost crond[699]: reading /var/spool/cron/cron.update
Jun  9 20:44:01 localhost crond[699]: failed parsing crontab for user mostafa: /sbin/shutdown -h -P -t secs now 

Offline

#11 2012-06-08 16:26:09

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Why do you keep starting new threads for the continuation of the same problem. Merging...


...as soon as I can find your old thread....

EDIT : Done

Last edited by Inxsible (2012-06-08 16:28:15)


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#12 2012-06-08 16:31:03

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Your syntax for the cron job is incorrect and so is your shutdown command.

If you are providing the now flag, you don't need the -t secs --- not to mention that -t requires the seconds in digits ...not the actual word "secs"


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#13 2012-06-08 16:56:17

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

I delete -t option from crontab , but still can not work

Offline

#14 2012-06-08 19:21:35

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,447

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Copy the command and try it in bash.

Offline

#15 2012-06-08 19:39:18

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Strike0 wrote:

Copy the command and try it in bash.

I copy it in terminal and this command work and turn off my system and system shutdown

Last edited by mfaridi (2012-06-08 19:39:41)

Offline

#16 2012-06-08 19:52:51

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Try this:

35 20   * * *   /sbin/shutdown -h -P now 

It should poweroff your system at 8:35 pm. however I am not sure how you are going to supply the password to it.

You might have to add the NOPASSWD flag to the /sbin/shutdown command in sudoers for your user.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#17 2012-06-08 20:13:21

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

I change the time of shutdown and use this link for sudo shutdown and password

http://linux.byexamples.com/archives/31 … -password/

but nithing happen and I see this error again

Jun 10 00:55:01 localhost crond[698]: reading /var/spool/cron/cron.update
Jun 10 00:55:01 localhost crond[698]: failed parsing crontab for user mostafa: /sbin/shutdown -h -P  now 

Last edited by mfaridi (2012-06-08 20:13:52)

Offline

#18 2012-06-08 20:17:24

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

show us your sudoers file and your crontab file.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#19 2012-06-08 20:22:13

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

I have one user my username is mostafa
this is

[root@mfaridiarch etc]# cat sudoers
## sudoers file.
##
## This file MUST be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
##

##
## Host alias specification
##
## Groups of machines. These may include host names (optionally with wildcards),
## IP addresses, network numbers or netgroups.
# Host_Alias    WEBSERVERS = www1, www2, www3

##
## User alias specification
##
## Groups of users.  These may consist of user names, uids, Unix groups,
## or netgroups.
# User_Alias    ADMINS = millert, dowdy, mikef

##
## Cmnd alias specification
##
## Groups of commands.  Often used to group related commands together.
# Cmnd_Alias    PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
#                           /usr/bin/pkill, /usr/bin/top

##
## Defaults specification
##
## You may wish to keep some of the following environment variables
## when running commands via sudo.
##
## Locale settings
# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET"
##
## Run X applications through sudo; HOME is used to find the
## .Xauthority file.  Note that other programs use HOME to find   
## configuration files and this may lead to privilege escalation!
# Defaults env_keep += "HOME"
##
## X11 resource path settings
# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH"
##
## Desktop path settings
# Defaults env_keep += "QTDIR KDEDIR"
##
## Allow sudo-run commands to inherit the callers' ConsoleKit session
# Defaults env_keep += "XDG_SESSION_COOKIE"
##
## Uncomment to enable special input methods.  Care should be taken as
## this may allow users to subvert the command being run via sudo.
# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER"
##
## Uncomment to enable logging of a command's output, except for
## sudoreplay and reboot.  Use sudoreplay to play back logged sessions.
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!/usr/local/bin/sudoreplay !log_output
# Defaults!/sbin/reboot !log_output

##
## Runas alias specification
##

##
## User privilege specification
##
root ALL=(ALL) ALL

## Uncomment to allow members of group wheel to execute any command
 %wheel ALL=(ALL) ALL

## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL

## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw  # Ask for the password of the target user
# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'

## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d


mostafa  ALL = NOPASSWD: /sbin/shutdown

and this is my crontab file create by mostafa user

[mostafa@mfaridiarch ~]$ crontab -l

59 0   *   /sbin/shutdown -h -P  now 
[mostafa@mfaridiarch ~]$ 

Offline

#20 2012-06-08 20:43:58

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: I have ADSL connection and I want at 8 morning my arch linux stop

As I told you in my earlier post as well, your crontab should be

59 0 * * * /sbin/shutdown -h -P now

Do you notice the difference? There are 3 asterisks (*) instead of just 1 like you have it since you only want to set the hour and minute. This will shutdown your machine at 12:59 am everyday.

You will have to wait until 12:59 am to test it obviously. For testing you should change the time to be within the next 5 minutes and see if it works. If it does, you can change it back to whatever you originally wanted to set it at.

Please read up on what cron is and how it works.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#21 2012-06-08 20:49:41

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

thanks I edit it . but nothing happen and I see this log

Jun 10 01:31:01 localhost crond[698]: reading /var/spool/cron/cron.update
Jun 10 01:32:01 localhost crond[698]: FILE /var/spool/cron/mostafa USER mostafa PID 1655 /sbin/shutdown -h -P  now 
Jun 10 01:32:01 localhost crond[698]: exit status 1 from user mostafa /sbin/shutdown -h -P  now 
Jun 10 01:32:01 localhost crond[1656]: mailing cron output for user mostafa /sbin/shutdown -h -P  now 
Jun 10 01:32:01 localhost crond[1656]: unable to exec /usr/sbin/sendmail: cron output for user mostafa /sbin/shutdown -h -P  now  to /dev/null

Offline

#22 2012-06-08 21:12:40

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: I have ADSL connection and I want at 8 morning my arch linux stop

mfaridi wrote:

I change the time of shutdown and use this link for sudo shutdown and password

http://linux.byexamples.com/archives/31 … -password/

You say you used that link to work out how to use sudo (method 2) ... but then don't use it in your crontab? Did you implement the suid bit (method 1)?

Last edited by vacant (2012-06-08 21:13:47)

Offline

#23 2012-06-08 21:46:36

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,447

Re: I have ADSL connection and I want at 8 morning my arch linux stop

vacant wrote:

You say you used that link to work out how to use sudo (method 2) ... but then don't use it in your crontab?

There should be no need to use sudo with that method because there is a named user (mostafa) in the sudoers now and it looks ok, IMO. No idea why it does not work like that right now. Maybe do a crontab for root? (I would prefer that to using suid personally).

edit: Above was wrong. I tried it here, vacant is right. With that method 2 above one still has to add "sudo" before the /sbin/shutdown command in crontab for it to get executed, even if the user is named in the sudoers file.

Last edited by Strike0 (2012-06-08 23:21:28)

Offline

#24 2012-06-09 11:31:31

mfaridi
Member
Registered: 2010-12-15
Posts: 192

Re: I have ADSL connection and I want at 8 morning my arch linux stop

I put sudo before shutdown command but , it can not work and can not shutdown my system , so this my crontab

 59 15 * *  * sudo  /sbin/shutdown -h -P  now 

but when I run this command

 [mostafa@mfaridiarch ~]$ sudo  /sbin/shutdown -h -P  now

in terminal I see this error

sudo: parse error in /etc/sudoers near line 93
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

this is line 93 of  /etc/sudoers

mostafa  ALL = NOPASSWD: /sbin/shutdown

I think this line has problem but I do not understand problem

Offline

#25 2012-06-09 11:54:07

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,447

Re: I have ADSL connection and I want at 8 morning my arch linux stop

Add a carriage return/CR at the end of it so that you have an empty line under it in the sudoers file, like this:

mostafa  ALL = NOPASSWD: /sbin/shutdown
## end of file

and try again if that makes a change.

Offline

Board footer

Powered by FluxBB