Hot answers tagged

12

You can pick any editor you like by setting the $EDITOR variable before calling crontab -e e.g. $ EDITOR=emacs crontab -e will run emacs as your editor. If you have a favourite editor then you can select that. Many programs that call an external editor may also use this $EDITOR variable so you may find it useful to set it permanently in your .profile ...


6

Files in /etc/cron.d need to also list the user that the job is to be run under. i.e. 0,15,30,45 * * * * root /backup.sh >/dev/null 2>&1 You should also ensure the permissions and owner:group are set correctly (-rw-r--r-- and owned by root:root)


6

You can use Anacron for this, it is designed to run jobs at certain intervals without assuming that the system is on continuously. If a job is supposed to be run every month, Anacron will check whether it has run in the previous month, and run it if it hasn't (and remember that it doesn't need to run it again for another month). In Debian derivatives, ...


5

That looks like vi or one of its many clones, probably vim. You can use i to insert, x to delete the current character, dd to delete a line (and copy it to clipboard), p to paste below the current line, and u to undo the last change. Hopefully that will be enough to let you do your change. For more details, search for a vi manual, handbook, or ...


4

The ... 1&2>> ... is viewed as ... 1& and then 2>> .... In other words, it starts the first part in the background, creates a log file, and try to start 2 which certainly does nothing. So no output is sent to that log file. I usually do something like 2>&1 to say to send stderr to stdout. You have to define stdout first if you ...


3

crontab -e enters into default editor (vi editor). The simple shortcuts in vi editor are i - Insert mode (allows you to write data) : mode :w -> we can save data :q -> quit from editor :q! -> force quit :wq -> save and quit any time we can reset the mode of editor by using Esc key. You can use EDITOR=nano crontab -e to edit crontab file by using the ...


3

SSH is just a way of logging in. If you are logged in as you say, you don't need SSH anymore. A command to shutdown is shutdown -h now. You edit your current user's crontab with crontab -e. In a user's crontab, the line to execute he above statement should be 0 21 * * * /sbin/shutdown -h now


3

It seems fcron is the right tool: "fcron makes no assumptions on whether your system is running all the time or regularly : you can, for instance, tell fcron to execute tasks every x hours y minutes of system up time or to do a job only once in a specified interval of time."


2

You have a couple of options here: Check the modification date of the file to see if it's being updated: ls -l /var/backups/your-file.sql If you haven't quite migrated over to systemd yet, cron should be logging to /var/log/syslog, in which case you can do something like this and check the timestamps: cat /var/log/syslog | grep -i cron If you are ...


2

If you're the only user on this computer, you might want to use just crontab -e. You'll be prompted to select an editor the first time you run the command. Then you can add this to it: 0,15,30,45 * * * * /backup.sh >/dev/null 2>&1 If you change to a normal user account, you'll need to use sudo crontab -e to configure the scripts you want ...


2

my best idea so far to check first if the content matches what should be in there and only update if it doesn't: if [[ $(crontab -l | egrep -v "^(#|$)" | grep -q 'something'; echo $?) == 1 ]] then echo $(crontab -l ; echo '* 1 * * * something') | crontab - fi but this gets complicated enough to build a separate script around that cron task. other ...


1

It may be due to many reasons. /*First of all, I gotta say this is more related to serverfault.com not here.*/ It is so ordinary not being able to access the external address of the network from within the internal network and itself since the traffic from the external address is sent back to the internal network. So it can most likely be DNS issue, and as ...


1

Checking the source code is the way to go: tmux only looks at the system's notion of the size in check-size, and before that, when attaching to or creating a session, it starts with 24x80. The latter is configurable with the command-line -x and -y options. The manual page lists this in new-session: The new session is attached to the current terminal ...


1

I highly recommend using Ansible* for this rather than rolling your own. Or Puppet or Chef — but Ansible is well-suited for zero-infrastructure deploy scripts like this. That's because there are already modules meant to solve problems like this, and config management tools have have idempotence as a basic design goal — that's the property of only changing ...


1

For the record I'm going to suggest using /etc/cron.d/. Only root can write files here but the entries can be run as any user (without need for sudo). echo '0 0 * * 0 webadmin /usr/local/bin/tidy_logfiles' > ~/webadmin.cron scp -p ~/webadmin.cron root@remote_host:/etc/cron.d/webadmin This can be applied multiple times, updating the local webadmin.cron ...


1

Use autossh, which does this for you. It is designed for persistent connections that don't need manual starting or restarting, are self monitored, and do any of the same tunneling jobs that a normal ssh client does.


1

You can do something like, 0 0 * * 5 /usr/bin/python /var/scripts/PLW.pl && /bin/bash /path/to/run_once.bash Note : && /bin/bash /path/to/run_once.bash will only run if previous command run successfully. So instead of using exit code, you can use &&'s inbuilt functionality.


1

Normally, sudo will be useless in a crontab. The cron program runs the commands in a restricted environment (most notably a very limited PATH and no controlling tty). While you could probably get this to work by installing severe security holes, the right way to achieve what you probably want is to put the command shutdown -r now in root's crontab. You ...



Only top voted, non community-wiki answers of a minimum length are eligible