What i already tried are:
scheduler extension which is clearly showing me that job in list view. Also when i try to run job manually it works but it doesn't come automatically on table all other job shows up fine. I am struggling since so many days .Please help.
I usually manage my cronjobs via SSH. From there, I use the following commands:
sudo crontab -e
This should bring up your cronjobs. To add cronjobs, simply start typing.
After you are done, hit the "ESC" key and type ":x" then hit the "Enter" key
To make sure that your cronjobss don't have any errors, type "sudo crontab -l"
Hopefully this helps
Related
I would like to point out that I tried A LOT of different tutorials from the internet but they don't seem to work...
Adding stuff to init.d, rc.local etc. for some reason it doesn't work.
I'm really desperate to get this done, but I'm a total noob when it comes to linux.
when I type in "matchbox-keyboard" it runs just fine and as intended.
That's literally all I want, but I'd like to run it every time so when I turn my raspberry pi on, I won't have to connect a keyboard and a mouse to initialize on-screen keyboard.
Is there a simple way to get this done, something like dropping the program into autostart folder in windows?
I have no experience with linux at all, I don't know how to write scrips and all that stuff and all I want is to run this "matchbox-keyboard" after every reboot...
Please help me, I'm really desperate and I can't figure it out. Spent all day doing it and still nothing...
The simplest way is to drop in a new cronjob (a cronjob is a task that is scheduled to run at a particular time):
crontab -e
This allows you to edit your cron file. Instead of putting in a time, use #reboot. So you should have a new line in your cronjob file that looks like this:
#reboot matchbox-keyboard
The cronjobs run in a different environment from your login environment, so you may need to use the full path to the program. I'm also not familiar with the matchbox-keyboard program, but it looks like it will run fine since it can run as a background process.
Maybe you have gnome-tweaks installed?
apt list gnome-tweaks
Listing... Done
gnome-tweaks/stable,now 3.30.2-1 all [installed,automatic]
It has a graphical Startup Applications function that allows you to select application icons and start them at LOGIN time. I use it to start my favorite text editor.
Starting things like an Apache server (e.g. XAMPP) at BOOT time is a whole new ball game. I used this link as a starting point.
I've setup a cron job by Ansible but when I use crontab -l it's said that my cron is empty.
Here's my script to set it up.
- name: Setup cron to run backup.sh every midnight
cron:
name="Backup S3 to GS"
minute="0"
hour="0"
job="sh ~/backup.sh"
cron_file=backup_s3
user=vagrant
But when I go inside the vagrant machine and ls /etc/cron.d/ I can see that backup_s3 file is there. But when I use command crontab -l it's said it's empty.
This is the content of backup_s3
#Ansible: Backup S3 to GS
0 0 * * * vagrant sh ~/backup.sh
I know that it's not running because I don't get any email saying that the backup is done and when I run the script manually it's working fine.
Okay. There are several layers of confusion here.
First, the crontab you see when you edit (crontab -e) or view (crontab -l) is a user cron. This sits in a magic spool directory/file. You can't edit it directly (approximately speaking), and it's not a good place to put any serious crons.
Since you are using cron_file=, Ansible is doing the appropriate thing by placing an entry in /etc/cron.d/. That means individual files can be placed there, which is much more sane than trying to edit a document. (look at all the people struggling with lineinfile here on stackoverflow)
This is why it isn't showing up in crontab -l, and it's a good thing.
As far as output from cron is concerned, does email even work for your Vagrant system? It likely doesn't. There are good ways around this. First, look at /var/log/cron. If you don't have one, look for CRON entries in /var/log/syslog. They may indicate if there are problems.
Next, crons typically don't have good access to a user shell. That means you should avoid ~. Further, if your permissions are wrong on backup.sh, it may not get executed. Finally, you can pipe output so you can see it. Here's what I'd recommend doing with your cron entry:
job="/bin/sh /home/vagrant/backup.sh >> /home/vagrant/backup.log"
You can also modify the minute/hour so it runs more frequently- so you don't have to wait overnight to see what is happening.
Once you've done that, you have plenty of places to look for information. There are two places in /var/log, there's a new backup.log which will give you information (if it exists, the cron has been run; if there is data in it, you should be able to figure out any problems).
TLDR
Change the job line. Look for execution in /var/log and /home/vagrant/backup.log.
I have to connect to a linux server from my own Ubuntu machine and operate directly on the server.
A dozen of folder names are listed in a LIST file. How to write sth. (like a bash script?) to carry out the following procedures?
for fold_name in LIST {
/******on my own Ubuntu*******/
-- open 2 new tabs of prompt terminal
-- run an ssh command in both
-- then input passwd and log in automatically in both
/******on the linux server*******/
-- cd to directory xxx/fold_name in both
-- run aaa.exe in 1st tab
-- vim sth in the 2nd tab
}
Once the loop of open-tab-login is solved, I guess the second part is routine as simple bash script except that I don't know how to specify between 2 tabs, either.
The point is I want all tabs in the same terminal. To this end, manually, I often Ctrl+Alt+T to create a prompt and Ctrl+Shift+T to open many tabs within it. And ssh...cd...... in each one. You see how annoying and cumbersome it is!
There are a few things you might like to research, which will get you a little closer.
You can run an ssh without a password, if you use an ssh key. Check out ssh-keygen, and the -i option in ssh.
Opening up tabs in gnome-terminal can be done via the method described here: Open a new tab in gnome-terminal using command line
You can run specific commands (e.g. aaa.exe) on a remote box over ssh, by including the command after the ssh: ssh user#remotehost aaa.exe.
If you want multiple commands, try enclosing them in quotes: ssh user#remotehost "cd /xxx; aaa.exe". Vim does not need to be in the directory in question in most cases: ssh user#remotehost vim /xxx/filename"
If you want to do something interactive (like vim), include the -t flag in ssh.
The tabs will be independent of each other - I'd probably run half of the command in one window, the other (e.g. runnning aaa.exe in one window, using one command, and the vim in another window, using another command, that I just happen to run at the same time. This way I can resize the windows, and arrange them relative to each other, and see both at once.
-- open 2 new tabs of prompt terminal
This depends on which desktop you're using. For gnome, gnome-terminal takes the -e option to specify the script to execute in the new terminal window. So, for something like this, you would execute gnome-terminal -e $script &, placing each instance of gnome-terminal in the background.
If you're using a different desktop, other terminal applications typically have a similar option. So, you'd point the terminal application to a script that's going to run in the terminal, and complete the rest of your task for you.
-- run an ssh command in both
-- then input passwd and log in automatically in both
This is going to be more complicated. The classical solution is the expect utility. There might be other similar tools that do similar things, but expect is pretty much the usual way these kinds of things have been done in the past. When it comes to trying to automate an interactive application, expect is really the only way to go. Unfortunately, expect uses a somewhat arkane syntax, that first-time users typically find confusing, and hard to understand. I grumble, every time I see no other alternative but to use expect to automate something, but this is pretty much the only option that's usually available.
I have an existing qlogin job like this:
job-ID prior name user state submit/start at queue
-------------------------------------------------------------------------
3530770 0.50500 QLOGIN jlsmith r 10/15/2012 14:02:07 mri.q#compute-0-29.local
The above job was submitted using standard qlogin command in linux:
$ qlogin
What I want to do is to perform another qlogin so that the process
are running in the same node with the above Job-ID 3530770.
The idea is that if it's done correctly in top command I can see the same running
process submitted to the above job-ID.
Is there a way to do it?
Either
qlogin -l h=compute-0-29.local
or
qlogin -q "*#compute-0-29.local"
Should do the job
Based on talking to some HPC specialists at work and some Google searching on the subject (I also wanted to resume a job ID), it's not really possible if you've already submitted the job. You can qlogin -q <node name> into the node again, but you cannot resume the job on the shell screen.
If you are thinking of starting a new qlogin job, but you would like to be able to resume it at some future point, then you can use screen to do this.
Before you write qlogin into the command line at the front-end node, write screen. It should completely clear the terminal screen.
Now qlogin and put in your job script interactively.
Once your job has started running and you want to leave for a bit, press and hold Cntl while you press A and D. It should say that your screen was detached and take you back to the front-end node. If you qstat now, you should see your job running.
When you want to resume the job ID (see the running process on the terminal screen), in the front-end node write screen -r. You should be able to see your running process in the terminal again.
Note: if you do this several times and you accumulate multiple screens by accident (happens to me every time), when you screen -r you will get multiple choices instead of automatically resuming the one you want. To try each one out, type screen -r <name of screen listed> one at a time until you find the one you want (detach as specified above). To get rid of the extra screens, write screen -D -r <name>.
Hope this helps.
I am using Putty to connect to a remote server. What I want to know is if there is any way to write my commands and allow them to keep running after I close the session with Putty. The reason for this is that I do not want to keep the computer ON all the time. Is there any way to do this?.
Update with the solution
For my question as it is presented the best solution is use one of the commands provided such as nohup, because you do not have to install any additional software. But if you are in the same problem use screen, install it and use it. It is amazing.
I have selected the answer of Norman Ramsey as favourite because propose several solutions using commands and screen. But please check the other answers specially the one of PEZ, then you get an insight of what screen is able todo.
screen! It's the best thing since sliced bread. (Yeah, I know others have already suggested it, but it's so good the whole world should join in and suggest it too.)
screen is like, like, ummmm ... like using VNC or the like to connect to a GUI destop, but for command shell windows. You can have several shell "windows" open at once in the same screen session. You can do stuff like:
Start a screens session using "screen -dR" (get used to using -dR)
run some commands in one window
press CTRL-A,C to create a new window open a file there in vim
press CTRL-A,0 to go back to the first window and issue some command on the file you just edited
CTRL-A, 1 to go back to your vim session
CTRL-A, C for yet another window and maybe do "sudo - su" (because you just happen to need a full root shell)
CTRL-A, 0 and start a background process
CTRL-A, C to create yet a new window, "tail -f" the log for that background process
CTRL-A, d to disconnect your screen then CTRL-D to disconnect from the server
Go on vacation for three weeks
Log on to the server again and issue "screen -dR" to connect to your existing screen session
check the log in the the fourth window with CTRL-A, 3 (it's like you've been there watching it all the time)
CTRL-A, 1 to pick up that vim session again
I guess you're starting to get the picture now? =)
It's like magic. I've been using screen for longer than I can remember and I'm still totally amazed with how bloody great it is.
EDIT: Just want to mention there's now also tmux. Very much like screen, but has some unique features, splitting the windows being the most prominent one.
nohup, disown, and screen are all good but screen is the best because unlike the other two, screen allows you to disconnect from the remote server, keep everything running, and then reconnect later to see what is happening. With nohup and disown you can't resume interacting.
Try using GNU Screen. It allows you to have several shells open at once. And you can disconnect from those running shells (i.e. close session with Putty) and they will keep doing their thing.
What you are looking for is nohup.
See the wiki link for how to use it.
screen is the best.
Try:
screen -dmS "MyTail" tail -f /var/log/syslog
This start command in background.
Use screen -r to list, and or screen -r Mytail to enter session.
If more users need access same session, use: screen -rx MyTail, and both or more users share the session.
If you can't use screen (because, for instance, your SSH session is being programmatically driven), you can also use daemonize to run the program as a daemon.
One way that works well for me is at.
at works like cron, but for a one-time job. I used it today to download a large file without having to keep my session alive.
for example:
$ at 23:55
at> wget http://file.to.download.com/bigfile.iso
at> ^D
You pass at a time (in the future) and it gives you a prompt. You enter the commands you want to run at that time and hit ctrl+d. You can exit out of your session and it will run the commands at the specified time.
Wikipedia has more info on at.
./command & disown
ssh localhost && ./command && exit