Many investors search for safe, dividend-paying stocks. As John D. Rockefeller once said: "Do you know the only thing that gives me pleasure? It's to see my dividends coming in."

This is particularly compelling while we are in a recession with so much uncertainty created by the coronavirus. Under these circumstances, there's comfort in companies that you can buy and hold for a very long time.

Below are two such stocks that you can put away and watch your dividends accumulate.

An ever-increasing pile of gold coins next to a piggy bank.

Image source: Getty Images.

Walmart

Walmart (WMT -0.73%) has raised its dividend annually since initiating a payment in 1974. That makes it a Dividend Aristocrat, and in a few years it should become a Dividend King (an elite group of S&P 500 companies that have increased dividends for 50 straight years).

While others have suspended dividends due to the pandemic's uncertainty, it is comforting to know that the company raised the quarterly payment this year from $0.53 to $0.54 per share, for a 1.7% dividend yield based on the current stock price.

Recent results back up that dividend decision. Fiscal second-quarter 2021 sales, covering the period that ended July 31, were over $140 billion after excluding foreign exchange, 7.5% higher than a year ago. Meanwhile, Walmart's adjusted operating income rose nearly 19% to $6.6 billion.

There's certainly plenty of cash flow to pay dividends. During the first half of the year, it generated free cash flow of $15.4 billion compared with its $3 billion in dividends.

While the pandemic has helped boost demand for certain products, this is a company that has proven staying power in all kinds of economic environments. Walmart opened its first discount store in the early 1960s, and its drive to keep down costs and pass along savings in the form of low prices has made the company into a powerhouse.

Better yet, management is adapting to the times by improving its e-commerce business, with online sales nearly doubling in the quarter. With reports that it is planning to launch its own subscription service, it is even taking on Amazon (AMZN -0.63%).

Procter & Gamble

Procter & Gamble (PG -0.20%), which has raised its payout every year since 1957, is a Dividend King. It has paid a dividend since 1890. Clearly, it will take a lot for the company to cut its payment. Even the challenges brought on by COVID-19 couldn't prevent Procter & Gamble from raising its payout, with the board of directors boosting its quarterly dividend from $0.746 to $0.791. This currently offers investors a 2.3% yield.

Results for its fiscal fourth quarter (ended June 30) benefited from people buying cleaning products, with adjusted sales increasing by 6%.

But the company, founded in 1837, has built strong and well-recognized brands that do well no matter the state of the economy, including shampoo, deodorant, razors, toothpaste, laundry detergent, and diapers sold under brands like Head & Shoulders, Gillette, Crest, Luvs, and Pampers. People don't brush their teeth fewer times or change their babies' diapers less frequently in a recession.

Procter & Gamble's free cash flow has grown for the last several years, going from 2017's $11.1 billion to $14.3 billion last year, giving it ample capacity to pay fiscal 2020's $7.8 billion in dividends.